RTEMS: cpukit/include/rtems/score/semaphoreimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
semaphoreimpl.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved.
11 *
12 * embedded brains GmbH
13 * Dornierstr. 4
14 * 82178 Puchheim
15 * Germany
16 * <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef _RTEMS_SCORE_SEMAPHOREIMPL_H
24#define _RTEMS_SCORE_SEMAPHOREIMPL_H
25
26#include <sys/lock.h>
27
28#include <rtems/score/percpu.h>
29#include <rtems/score/threadqimpl.h>
30
37#ifdef __cplusplus
38extern "C" {
39#endif /* __cplusplus */
40
41 typedef struct {
42 Thread_queue_Syslock_queue Queue;
43 unsigned int count;
44} Sem_Control;
45
46#define SEMAPHORE_TQ_OPERATIONS &_Thread_queue_Operations_priority
47
55static inline Sem_Control *_Sem_Get( struct _Semaphore_Control *_sem )
56{
57 return (Sem_Control *) _sem;
58}
59
70static inline Thread_Control *_Sem_Queue_acquire_critical(
71 Sem_Control *sem,
72 Thread_queue_Context *queue_context
73)
74{
75 Thread_Control *executing;
76
77 executing = _Thread_Executing;
78 _Thread_queue_Queue_acquire_critical(
79 &sem->Queue.Queue,
80 &executing->Potpourri_stats,
81 &queue_context->Lock_context.Lock_context
82 );
83
84 return executing;
85}
86
94static inline void _Sem_Queue_release(
95 Sem_Control *sem,
96 ISR_Level level,
97 Thread_queue_Context *queue_context
98)
99{
100 _Thread_queue_Queue_release_critical(
101 &sem->Queue.Queue,
102 &queue_context->Lock_context.Lock_context
103 );
104 _ISR_Local_enable( level );
105}
106
107#ifdef __cplusplus
108}
109#endif /* __cplusplus */
110
113#endif /* _RTEMS_SCORE_SEMAPHOREIMPL_H */
_ISR_Local_enable
#define _ISR_Local_enable(_level)
Enables interrupts on this processor.
Definition: isrlevel.h:74
ISR_Level
uint32_t ISR_Level
Definition: isrlevel.h:41
_Thread_queue_Queue_release_critical
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Releases the thread queue queue in a critical section.
Definition: threadqimpl.h:603
percpu.h
Sem_Control
Definition: semaphoreimpl.h:41
Thread_queue_Context
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Thread_queue_Context::Lock_context
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
Thread_queue_Lock_context::Lock_context
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Thread_queue_Syslock_queue
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:54
_Thread_Control
Definition: thread.h:732
threadqimpl.h
Constants and Structures Associated with the Manipulation of Objects.