source: rtems/cpukit/posix/src/cancelrun.c @ 1f6138e5

4.115
Last change on this file since 1f6138e5 was 0c5317d, checked in by Sebastian Huber <sebastian.huber@…>, on 07/19/13 at 12:33:56

posix: Create pthread implementation header

Move implementation specific parts of pthread.h and pthread.inl into new
header file pthreadimpl.h. The pthread.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Executes a thread's cancellation handlers
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
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 <pthread.h>
22#include <errno.h>
23
24#include <rtems/system.h>
25#include <rtems/score/chain.h>
26#include <rtems/score/isr.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/posix/cancel.h>
30#include <rtems/posix/pthreadimpl.h>
31#include <rtems/posix/threadsup.h>
32
33void _POSIX_Threads_cancel_run(
34  Thread_Control *the_thread
35)
36{
37  POSIX_Cancel_Handler_control      *handler;
38  Chain_Control                     *handler_stack;
39  POSIX_API_Control                 *thread_support;
40  ISR_Level                          level;
41
42  thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];
43
44  handler_stack = &thread_support->Cancellation_Handlers;
45
46  thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;
47
48  while ( !_Chain_Is_empty( handler_stack ) ) {
49    _ISR_Disable( level );
50      handler = (POSIX_Cancel_Handler_control *)
51           _Chain_Tail( handler_stack )->previous;
52      _Chain_Extract_unprotected( &handler->Node );
53    _ISR_Enable( level );
54
55    (*handler->routine)( handler->arg );
56
57    _Workspace_Free( handler );
58  }
59}
Note: See TracBrowser for help on using the repository browser.