source: rtems/cpukit/score/src/threadclose.c @ dcf3687

4.115
Last change on this file since dcf3687 was dcf3687, checked in by Joel Sherrill <joel.sherrill@…>, on 01/28/11 at 20:24:54

2011-01-28 Joel Sherrill <joel.sherrilL@…>

  • include/rtems/bspIo.h, include/rtems/concat.h, include/rtems/irq.h, score/cpu/i386/rtems/score/idtr.h, score/cpu/powerpc/rtems/powerpc/registers.h, score/src/objectidtoname.c, score/src/schedulerpriorityblock.c, score/src/schedulerpriorityschedule.c, score/src/schedulerpriorityunblock.c, score/src/schedulerpriorityyield.c, score/src/thread.c, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadclose.c, score/src/threadcreateidle.c, score/src/threaddelayended.c, score/src/threaddispatch.c, score/src/threadget.c, score/src/threadhandler.c, score/src/threadinitialize.c, score/src/threadloadenv.c, score/src/threadready.c, score/src/threadreset.c, score/src/threadrestart.c, score/src/threadresume.c, score/src/threadsetpriority.c, score/src/threadsetstate.c, score/src/threadsettransient.c, score/src/threadstackallocate.c, score/src/threadstackfree.c, score/src/threadstart.c, score/src/threadstartmultitasking.c, score/src/threadsuspend.c, score/src/threadtickletimeslice.c, score/src/threadyieldprocessor.c: Fix typo where license said found in found in.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  Thread Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2008.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/apiext.h>
21#include <rtems/score/context.h>
22#include <rtems/score/interr.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/object.h>
25#include <rtems/score/priority.h>
26#include <rtems/score/scheduler.h>
27#include <rtems/score/states.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/thread.h>
30#include <rtems/score/threadq.h>
31#include <rtems/score/userext.h>
32#include <rtems/score/wkspace.h>
33
34/*
35 *  _Thread_Close
36 *
37 *  DESCRIPTION:
38 *
39 *  This routine frees all memory associated with the specified
40 *  thread and removes it from the local object table so no further
41 *  operations on this thread are allowed.
42 */
43
44void _Thread_Close(
45  Objects_Information  *information,
46  Thread_Control       *the_thread
47)
48{
49
50  /*
51   *  Now we are in a dispatching critical section again and we
52   *  can take the thread OUT of the published set.  It is invalid
53   *  to use this thread's Id after this call.  This will prevent
54   *  any other task from attempting to initiate a call on this task.
55   */
56  _Objects_Invalidate_Id( information, &the_thread->Object );
57
58  /*
59   *  We assume the Allocator Mutex is locked when we get here.
60   *  This provides sufficient protection to let the user extensions
61   *  run but as soon as we get back, we will make the thread
62   *  disappear and set a transient state on it.  So we temporarily
63   *  unnest dispatching.
64   */
65  _Thread_Unnest_dispatch();
66
67  _User_extensions_Thread_delete( the_thread );
68
69  _Thread_Disable_dispatch();
70
71  /*
72   *  Now we are in a dispatching critical section again and we
73   *  can take the thread OUT of the published set.  It is invalid
74   *  to use this thread's Id OR name after this call.
75   */
76  _Objects_Close( information, &the_thread->Object );
77
78  /*
79   *  By setting the dormant state, the thread will not be considered
80   *  for scheduling when we remove any blocking states.
81   */
82  _Thread_Set_state( the_thread, STATES_DORMANT );
83
84  if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) {
85    if ( _Watchdog_Is_active( &the_thread->Timer ) )
86      (void) _Watchdog_Remove( &the_thread->Timer );
87  }
88
89  /*
90   * Free the per-thread scheduling information.
91   */
92  _Scheduler_Thread_scheduler_free( &_Scheduler, the_thread );
93
94  /*
95   *  The thread might have been FP.  So deal with that.
96   */
97#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
98#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
99  if ( _Thread_Is_allocated_fp( the_thread ) )
100    _Thread_Deallocate_fp();
101#endif
102  the_thread->fp_context = NULL;
103
104  if ( the_thread->Start.fp_context )
105    (void) _Workspace_Free( the_thread->Start.fp_context );
106#endif
107
108  /*
109   *  Free the rest of the memory associated with this task
110   *  and set the associated pointers to NULL for safety.
111   */
112  _Thread_Stack_Free( the_thread );
113  the_thread->Start.stack = NULL;
114
115  if ( the_thread->extensions )
116    (void) _Workspace_Free( the_thread->extensions );
117  the_thread->extensions = NULL;
118}
Note: See TracBrowser for help on using the repository browser.