source: rtems/cpukit/posix/src/cancel.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was 171bbec, checked in by Joel Sherrill <joel.sherrill@…>, on 10/10/09 at 16:03:38

2009-10-10 Joel Sherrill <joel.sherrill@…>

  • posix/include/rtems/posix/threadsup.h, posix/src/cancel.c, posix/src/canceleval.c: Make psxcancel run again. _POSIX_Thread_Exit() can be called on running thread or another thread when it is cancelled.
  • Property mode set to 100644
File size: 1.4 KB
Line 
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 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <pthread.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/score/chain.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/posix/cancel.h>
25#include <rtems/posix/pthread.h>
26#include <rtems/posix/threadsup.h>
27
28/*
29 *  18.2.1 Canceling Execution of a Thread, P1003.1c/Draft 10, p. 181
30 */
31
32int pthread_cancel(
33  pthread_t  thread
34)
35{
36  Thread_Control     *the_thread;
37  POSIX_API_Control  *thread_support;
38  Objects_Locations   location;
39
40  /*
41   *  Don't even think about deleting a resource from an ISR.
42   */
43
44  if ( _ISR_Is_in_progress() )
45    return EPROTO;
46
47  the_thread = _POSIX_Threads_Get( thread, &location );
48  switch ( location ) {
49
50    case OBJECTS_LOCAL:
51      thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];
52
53      thread_support->cancelation_requested = 1;
54
55      /* This enables dispatch implicitly */
56      _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( the_thread );
57      return 0;
58
59#if defined(RTEMS_MULTIPROCESSING)
60    case OBJECTS_REMOTE:
61#endif
62    case OBJECTS_ERROR:
63      break;
64  }
65
66  return EINVAL;
67}
Note: See TracBrowser for help on using the repository browser.