OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [src/] [cancelrun.c] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  cancelrun.c,v 1.4 2002/07/05 18:13:18 joel Exp
3
 */
4
 
5
#if HAVE_CONFIG_H
6
#include "config.h"
7
#endif
8
 
9
#include <pthread.h>
10
#include <errno.h>
11
 
12
#include <rtems/system.h>
13
#include <rtems/score/chain.h>
14
#include <rtems/score/isr.h>
15
#include <rtems/score/thread.h>
16
#include <rtems/score/wkspace.h>
17
#include <rtems/posix/cancel.h>
18
#include <rtems/posix/pthread.h>
19
#include <rtems/posix/threadsup.h>
20
 
21
/*PAGE
22
 *
23
 *  _POSIX_Threads_cancel_run
24
 *
25
 */
26
 
27
#if !defined(PTHREAD_CANCELED)
28
#warning "PTHREAD_CANCELED NOT DEFINED -- patch newlib"
29
#define PTHREAD_CANCELED ((void *) -1)
30
#endif
31
 
32
void _POSIX_Threads_cancel_run(
33
  Thread_Control *the_thread
34
)
35
{
36
  POSIX_Cancel_Handler_control      *handler;
37
  Chain_Control                     *handler_stack;
38
  POSIX_API_Control                 *thread_support;
39
  ISR_Level                          level;
40
 
41
  thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];
42
 
43
  handler_stack = &thread_support->Cancellation_Handlers;
44
 
45
  thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;
46
 
47
  while ( !_Chain_Is_empty( handler_stack ) ) {
48
    _ISR_Disable( level );
49
      handler = (POSIX_Cancel_Handler_control *) _Chain_Tail( handler_stack );
50
      _Chain_Extract_unprotected( &handler->Node );
51
    _ISR_Enable( level );
52
 
53
    (*handler->routine)( handler->arg );
54
 
55
    _Workspace_Free( handler );
56
  }
57
 
58
  /* Now we can delete the thread */
59
 
60
  the_thread->Wait.return_argument = (unsigned32 *)PTHREAD_CANCELED;
61
  _Thread_Close(
62
    _Objects_Get_information( the_thread->Object.id ),
63
    the_thread
64
  );
65
  _POSIX_Threads_Free( the_thread );
66
 
67
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.