1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2008. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #if HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <pthread.h> |
---|
15 | #include <errno.h> |
---|
16 | |
---|
17 | #include <rtems/system.h> |
---|
18 | #include <rtems/score/chain.h> |
---|
19 | #include <rtems/score/isr.h> |
---|
20 | #include <rtems/score/thread.h> |
---|
21 | #include <rtems/score/wkspace.h> |
---|
22 | #include <rtems/posix/cancel.h> |
---|
23 | #include <rtems/posix/pthread.h> |
---|
24 | #include <rtems/posix/threadsup.h> |
---|
25 | |
---|
26 | void _POSIX_Threads_cancel_run( |
---|
27 | Thread_Control *the_thread |
---|
28 | ) |
---|
29 | { |
---|
30 | POSIX_Cancel_Handler_control *handler; |
---|
31 | Chain_Control *handler_stack; |
---|
32 | POSIX_API_Control *thread_support; |
---|
33 | ISR_Level level; |
---|
34 | |
---|
35 | thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ]; |
---|
36 | |
---|
37 | handler_stack = &thread_support->Cancellation_Handlers; |
---|
38 | |
---|
39 | thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE; |
---|
40 | |
---|
41 | while ( !_Chain_Is_empty( handler_stack ) ) { |
---|
42 | _ISR_Disable( level ); |
---|
43 | handler = (POSIX_Cancel_Handler_control *) |
---|
44 | _Chain_Tail( handler_stack )->previous; |
---|
45 | _Chain_Extract_unprotected( &handler->Node ); |
---|
46 | _ISR_Enable( level ); |
---|
47 | |
---|
48 | (*handler->routine)( handler->arg ); |
---|
49 | |
---|
50 | _Workspace_Free( handler ); |
---|
51 | } |
---|
52 | } |
---|