source: rtems/cpukit/posix/src/cancel.c @ 77fbbd6

5
Last change on this file since 77fbbd6 was e266d13, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 13:10:27

Replace *_Get_interrupt_disable() with *_Get()

Uniformly use *_Get() to get an object by identifier with a lock
context.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Canceling Execution of a Thread
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  Copyright (c) 2016 embedded brains GmbH.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <pthread.h>
24#include <errno.h>
25
26#include <rtems/score/isr.h>
27#include <rtems/score/threadimpl.h>
28
29/*
30 *  18.2.1 Canceling Execution of a Thread, P1003.1c/Draft 10, p. 181
31 */
32
33int pthread_cancel( pthread_t thread )
34{
35  Thread_Control   *the_thread;
36  ISR_lock_Context  lock_context;
37  Thread_Control   *executing;
38  Per_CPU_Control  *cpu_self;
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
48  the_thread = _Thread_Get( thread, &lock_context );
49
50  if ( the_thread == NULL ) {
51    return ESRCH;
52  }
53
54  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
55  _ISR_lock_ISR_enable( &lock_context );
56
57  executing = _Per_CPU_Get_executing( cpu_self );
58
59  if ( the_thread == executing ) {
60    _Thread_Exit( executing, THREAD_LIFE_TERMINATING, PTHREAD_CANCELED );
61  } else {
62    _Thread_Cancel( the_thread, executing, PTHREAD_CANCELED );
63  }
64
65  _Thread_Dispatch_enable( cpu_self );
66  return 0;
67}
Note: See TracBrowser for help on using the repository browser.