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 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/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 | #include <rtems/config.h> |
---|
33 | |
---|
34 | /* |
---|
35 | * _Thread_Stack_Free |
---|
36 | * |
---|
37 | * Deallocate the Thread's stack. |
---|
38 | */ |
---|
39 | |
---|
40 | void _Thread_Stack_Free( |
---|
41 | Thread_Control *the_thread |
---|
42 | ) |
---|
43 | { |
---|
44 | #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) |
---|
45 | /* |
---|
46 | * If the API provided the stack space, then don't free it. |
---|
47 | */ |
---|
48 | if ( !the_thread->Start.core_allocated_stack ) |
---|
49 | return; |
---|
50 | #endif |
---|
51 | |
---|
52 | /* |
---|
53 | * Call ONLY the CPU table stack free hook, or the |
---|
54 | * the RTEMS workspace free. This is so the free |
---|
55 | * routine properly matches the allocation of the stack. |
---|
56 | */ |
---|
57 | |
---|
58 | if ( Configuration.stack_free_hook ) |
---|
59 | (*Configuration.stack_free_hook)( the_thread->Start.Initial_stack.area ); |
---|
60 | else |
---|
61 | _Workspace_Free( the_thread->Start.Initial_stack.area ); |
---|
62 | } |
---|