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

4.115
Last change on this file since d7c3883 was 108c4b0, checked in by Joel Sherrill <joel.sherrill@…>, on 02/18/11 at 15:12:44

2011-02-18 Joel Sherrill <joel.sherrill@…>

  • sapi/include/confdefs.h, score/Makefile.am, score/include/rtems/score/scheduler.h, score/include/rtems/score/schedulerpriority.h, score/include/rtems/score/thread.h, score/inline/rtems/score/scheduler.inl, score/inline/rtems/score/schedulerpriority.inl, score/src/scheduler.c, score/src/schedulerpriority.c, score/src/schedulerpriorityblock.c, score/src/schedulerpriorityschedule.c, score/src/schedulerpriorityunblock.c, score/src/schedulerpriorityyield.c, score/src/threadchangepriority.c, score/src/threadclose.c, score/src/threadinitialize.c, score/src/threadsetpriority.c, score/src/threadsettransient.c: Significant clean up on Scheduler Plugin Interface. Names were shortened. Missing operations added. Many scheduler files had unneeded includes removed. Made pointer to scheduler information in Thread_Control and Scheduler_Control a void * pointer because the thread and scheduler wrapper should be unaware of scheduler types AND this is broken for user provided schedulers.
  • score/src/schedulerpriorityallocate.c, score/src/schedulerpriorityenqueue.c, score/src/schedulerpriorityenqueuefirst.c, score/src/schedulerpriorityextract.c, score/src/schedulerpriorityfree.c, score/src/schedulerpriorityupdate.c: New files.
  • score/src/schedulerprioritythreadschedulerallocate.c, score/src/schedulerprioritythreadschedulerfree.c, score/src/schedulerprioritythreadschedulerupdate.c: Removed.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  Thread Handler / Thread Close
3 *
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/apiext.h>
20#include <rtems/score/context.h>
21#include <rtems/score/interr.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/priority.h>
25#include <rtems/score/scheduler.h>
26#include <rtems/score/states.h>
27#include <rtems/score/sysstate.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/threadq.h>
30#include <rtems/score/userext.h>
31#include <rtems/score/wkspace.h>
32
33void _Thread_Close(
34  Objects_Information  *information,
35  Thread_Control       *the_thread
36)
37{
38  /*
39   *  Now we are in a dispatching critical section again and we
40   *  can take the thread OUT of the published set.  It is invalid
41   *  to use this thread's Id after this call.  This will prevent
42   *  any other task from attempting to initiate a call on this task.
43   */
44  _Objects_Invalidate_Id( information, &the_thread->Object );
45
46  /*
47   *  We assume the Allocator Mutex is locked when we get here.
48   *  This provides sufficient protection to let the user extensions
49   *  run but as soon as we get back, we will make the thread
50   *  disappear and set a transient state on it.  So we temporarily
51   *  unnest dispatching.
52   */
53  _Thread_Unnest_dispatch();
54
55  _User_extensions_Thread_delete( the_thread );
56
57  _Thread_Disable_dispatch();
58
59  /*
60   *  Now we are in a dispatching critical section again and we
61   *  can take the thread OUT of the published set.  It is invalid
62   *  to use this thread's Id OR name after this call.
63   */
64  _Objects_Close( information, &the_thread->Object );
65
66  /*
67   *  By setting the dormant state, the thread will not be considered
68   *  for scheduling when we remove any blocking states.
69   */
70  _Thread_Set_state( the_thread, STATES_DORMANT );
71
72  if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) {
73    if ( _Watchdog_Is_active( &the_thread->Timer ) )
74      (void) _Watchdog_Remove( &the_thread->Timer );
75  }
76
77  /*
78   * Free the per-thread scheduling information.
79   */
80  _Scheduler_Free( the_thread );
81
82  /*
83   *  The thread might have been FP.  So deal with that.
84   */
85#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
86#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
87  if ( _Thread_Is_allocated_fp( the_thread ) )
88    _Thread_Deallocate_fp();
89#endif
90  the_thread->fp_context = NULL;
91
92  _Workspace_Free( the_thread->Start.fp_context );
93#endif
94
95  /*
96   *  Free the rest of the memory associated with this task
97   *  and set the associated pointers to NULL for safety.
98   */
99  _Thread_Stack_Free( the_thread );
100  the_thread->Start.stack = NULL;
101
102  _Workspace_Free( the_thread->extensions );
103  the_thread->extensions = NULL;
104}
Note: See TracBrowser for help on using the repository browser.