5
Last change
on this file since 0e16fa45 was
c090db7,
checked in by Sebastian Huber <sebastian.huber@…>, on 09/12/17 at 06:09:16
|
posix: Implement self-contained POSIX semaphores
For semaphore object pointer and object validation see
POSIX_SEMAPHORE_VALIDATE_OBJECT().
Destruction or close of a busy semaphore returns an error status. The
object is not flushed.
POSIX semaphores are now available in all configurations and no longer
depend on --enable-posix.
Update #2514.
Update #3116.
|
-
Property mode set to
100644
|
File size:
948 bytes
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Get the Value of a Semaphore |
---|
5 | * @ingroup POSIX_SEMAPHORE |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
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 <rtems/posix/semaphoreimpl.h> |
---|
22 | |
---|
23 | int sem_getvalue( |
---|
24 | sem_t *__restrict _sem, |
---|
25 | int *__restrict sval |
---|
26 | ) |
---|
27 | { |
---|
28 | Sem_Control *sem; |
---|
29 | ISR_Level level; |
---|
30 | Thread_queue_Context queue_context; |
---|
31 | |
---|
32 | POSIX_SEMAPHORE_VALIDATE_OBJECT( _sem ); |
---|
33 | |
---|
34 | sem = _Sem_Get( &_sem->_Semaphore ); |
---|
35 | _Thread_queue_Context_initialize( &queue_context ); |
---|
36 | _Thread_queue_Context_ISR_disable( &queue_context, level ); |
---|
37 | _Sem_Queue_acquire_critical( sem, &queue_context ); |
---|
38 | *sval = (int) sem->count; |
---|
39 | _Sem_Queue_release( sem, level, &queue_context ); |
---|
40 | return 0; |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.