1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Core Semaphore Initialize |
---|
5 | * @ingroup ScoreSemaphore |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
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/score/coresemimpl.h> |
---|
22 | |
---|
23 | void _CORE_semaphore_Initialize( |
---|
24 | CORE_semaphore_Control *the_semaphore, |
---|
25 | CORE_semaphore_Disciplines discipline, |
---|
26 | uint32_t initial_value |
---|
27 | ) |
---|
28 | { |
---|
29 | the_semaphore->count = initial_value; |
---|
30 | |
---|
31 | _Thread_queue_Initialize( &the_semaphore->Wait_queue ); |
---|
32 | |
---|
33 | if ( discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ) { |
---|
34 | the_semaphore->operations = &_Thread_queue_Operations_priority; |
---|
35 | } else { |
---|
36 | the_semaphore->operations = &_Thread_queue_Operations_FIFO; |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | Thread_Control *_CORE_semaphore_Was_deleted( |
---|
41 | Thread_Control *the_thread, |
---|
42 | Thread_queue_Queue *queue, |
---|
43 | Thread_queue_Context *queue_context |
---|
44 | ) |
---|
45 | { |
---|
46 | the_thread->Wait.return_code = CORE_SEMAPHORE_WAS_DELETED; |
---|
47 | |
---|
48 | return the_thread; |
---|
49 | } |
---|
50 | |
---|
51 | Thread_Control *_CORE_semaphore_Unsatisfied_nowait( |
---|
52 | Thread_Control *the_thread, |
---|
53 | Thread_queue_Queue *queue, |
---|
54 | Thread_queue_Context *queue_context |
---|
55 | ) |
---|
56 | { |
---|
57 | the_thread->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; |
---|
58 | |
---|
59 | return the_thread; |
---|
60 | } |
---|