RTEMS 6.1-rc7
Loading...
Searching...
No Matches
semaphoreimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2015, 2017 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_SCORE_SEMAPHOREIMPL_H
38#define _RTEMS_SCORE_SEMAPHOREIMPL_H
39
40#include <sys/lock.h>
41
42#include <rtems/score/percpu.h>
44
57#ifdef __cplusplus
58extern "C" {
59#endif /* __cplusplus */
60
61typedef struct {
63 unsigned int count;
65
66#define SEMAPHORE_TQ_OPERATIONS &_Thread_queue_Operations_priority
67
75static inline Sem_Control *_Sem_Get( struct _Semaphore_Control *_sem )
76{
77 return (Sem_Control *) _sem;
78}
79
90static inline Thread_Control *_Sem_Queue_acquire_critical(
91 Sem_Control *sem,
92 Thread_queue_Context *queue_context
93)
94{
95 Thread_Control *executing;
96
97 executing = _Thread_Executing;
98 _Thread_queue_Queue_acquire_critical(
99 &sem->Queue.Queue,
100 &executing->Potpourri_stats,
101 &queue_context->Lock_context.Lock_context
102 );
103
104 return executing;
105}
106
114static inline void _Sem_Queue_release(
115 Sem_Control *sem,
116 ISR_Level level,
117 Thread_queue_Context *queue_context
118)
119{
120 _Thread_queue_Queue_release_critical(
121 &sem->Queue.Queue,
122 &queue_context->Lock_context.Lock_context
123 );
124 _ISR_Local_enable( level );
125}
126
127#ifdef __cplusplus
128}
129#endif /* __cplusplus */
130
133#endif /* _RTEMS_SCORE_SEMAPHOREIMPL_H */
#define _ISR_Local_enable(_level)
Enables interrupts on this processor.
Definition: isrlevel.h:93
uint32_t ISR_Level
Definition: isrlevel.h:60
This header file provides the interfaces of the Per-CPU Information.
Definition: semaphoreimpl.h:61
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:221
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:148
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:71
Definition: thread.h:837
This header file provides interfaces of the Thread Queue Handler which are only used by the implement...