5
Last change
on this file since 127c20eb 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.1 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Detaching a Thread |
---|
5 | * @ingroup POSIXAPI |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
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/threadimpl.h> |
---|
27 | |
---|
28 | /** |
---|
29 | * 16.1.4 Detaching a Thread, P1003.1c/Draft 10, p. 149 |
---|
30 | */ |
---|
31 | int pthread_detach( pthread_t thread ) |
---|
32 | { |
---|
33 | Thread_Control *the_thread; |
---|
34 | ISR_lock_Context lock_context; |
---|
35 | Per_CPU_Control *cpu_self; |
---|
36 | |
---|
37 | the_thread = _Thread_Get( thread, &lock_context ); |
---|
38 | |
---|
39 | if ( the_thread == NULL ) { |
---|
40 | return ESRCH; |
---|
41 | } |
---|
42 | |
---|
43 | _Thread_State_acquire( the_thread, &lock_context ); |
---|
44 | |
---|
45 | the_thread->Life.state |= THREAD_LIFE_DETACHED; |
---|
46 | _Thread_Clear_state_locked( the_thread, STATES_WAITING_FOR_JOIN_AT_EXIT ); |
---|
47 | |
---|
48 | cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); |
---|
49 | _Thread_State_release( the_thread, &lock_context ); |
---|
50 | _Thread_Dispatch_enable( cpu_self ); |
---|
51 | return 0; |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.