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

4.115
Last change on this file since f2f63d1 was f2f63d1, checked in by Alex Ivanov <alexivanov97@…>, on 11/29/12 at 23:14:28

score misc: Score misc: Clean up Doxygen #7 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

https://google-melange.appspot.com/gci/task/view/google/gci2012/7986214

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