5
Last change
on this file since 8866e62 was
8866e62,
checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 04:26:58
|
score: Move thread queue object support
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief POSIX Semaphore Wait Support |
---|
5 | * @ingroup POSIXSemaphorePrivate |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2012. |
---|
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.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <semaphore.h> |
---|
22 | |
---|
23 | #include <rtems/posix/semaphoreimpl.h> |
---|
24 | |
---|
25 | THREAD_QUEUE_OBJECT_ASSERT( POSIX_Semaphore_Control, Semaphore.Wait_queue ); |
---|
26 | |
---|
27 | int _POSIX_Semaphore_Wait_support( |
---|
28 | sem_t *sem, |
---|
29 | bool blocking, |
---|
30 | Watchdog_Interval timeout |
---|
31 | ) |
---|
32 | { |
---|
33 | POSIX_Semaphore_Control *the_semaphore; |
---|
34 | Thread_Control *executing; |
---|
35 | ISR_lock_Context lock_context; |
---|
36 | |
---|
37 | the_semaphore = _POSIX_Semaphore_Get( sem, &lock_context ); |
---|
38 | |
---|
39 | if ( the_semaphore == NULL ) { |
---|
40 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
41 | } |
---|
42 | |
---|
43 | executing = _Thread_Executing; |
---|
44 | |
---|
45 | _CORE_semaphore_Seize( |
---|
46 | &the_semaphore->Semaphore, |
---|
47 | executing, |
---|
48 | blocking, |
---|
49 | timeout, |
---|
50 | &lock_context |
---|
51 | ); |
---|
52 | |
---|
53 | if ( executing->Wait.return_code == CORE_SEMAPHORE_STATUS_SUCCESSFUL ) { |
---|
54 | return 0; |
---|
55 | } |
---|
56 | |
---|
57 | rtems_set_errno_and_return_minus_one( |
---|
58 | _POSIX_Semaphore_Translate_core_semaphore_return_code( |
---|
59 | executing->Wait.return_code |
---|
60 | ) |
---|
61 | ); |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.