29 #include <rtems/sysinit.h> 31 #define SEMAPHORE_KIND_MASK ( RTEMS_SEMAPHORE_CLASS | RTEMS_INHERIT_PRIORITY \ 32 | RTEMS_PRIORITY_CEILING | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING ) 44 Status_Control status;
59 #if defined(RTEMS_MULTIPROCESSING) 60 if ( !_System_state_Is_multiprocessing ) {
66 maybe_global = attribute_set & SEMAPHORE_KIND_MASK;
73 variant = SEMAPHORE_VARIANT_COUNTING;
74 }
else if ( count > 1 ) {
81 variant = SEMAPHORE_VARIANT_SIMPLE_BINARY;
83 variant = SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL;
88 variant = SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY;
93 variant = SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING;
98 #if defined(RTEMS_SMP) 99 variant = SEMAPHORE_VARIANT_MRSP;
105 variant = SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING;
113 if ( !the_semaphore ) {
118 flags = _Semaphore_Set_variant( 0, variant );
120 #if defined(RTEMS_MULTIPROCESSING) 121 if ( _Attributes_Is_global( attribute_set ) ) {
124 ok = _Objects_MP_Allocate_and_open(
137 flags = _Semaphore_Make_global( flags );
142 flags = _Semaphore_Set_discipline( flags, SEMAPHORE_DISCIPLINE_PRIORITY );
144 flags = _Semaphore_Set_discipline( flags, SEMAPHORE_DISCIPLINE_FIFO );
147 _Semaphore_Set_flags( the_semaphore, flags );
151 case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
152 case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
165 status = STATUS_SUCCESSFUL;
167 case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
194 if ( status != STATUS_SUCCESSFUL ) {
198 status = STATUS_SUCCESSFUL;
201 status = STATUS_INVALID_PRIORITY;
205 #if defined(RTEMS_SMP) 206 case SEMAPHORE_VARIANT_MRSP:
219 status = STATUS_INVALID_PRIORITY;
226 variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
227 || variant == SEMAPHORE_VARIANT_COUNTING
233 status = STATUS_SUCCESSFUL;
237 if ( status != STATUS_SUCCESSFUL ) {
240 return _Status_Get( status );
255 #if defined(RTEMS_MULTIPROCESSING) 256 if ( _Attributes_Is_global( attribute_set ) )
257 _Semaphore_MP_Send_process_packet(
258 SEMAPHORE_MP_ANNOUNCE_CREATE,
268 static void _Semaphore_Manager_initialization(
void )
274 _Semaphore_Manager_initialization,
275 RTEMS_SYSINIT_CLASSIC_SEMAPHORE,
276 RTEMS_SYSINIT_ORDER_MIDDLE
This status code indicates you have attempted to create too many instances of a particular object cla...
static __inline__ void _Objects_Allocator_unlock(void)
Unlocks the object allocator mutex.
This header file defines support services of the API.
static __inline__ Priority_Control _RTEMS_Priority_To_core(const Scheduler_Control *scheduler, rtems_task_priority priority, bool *valid)
Converts the RTEMS API priority to the corresponding SuperCore priority and validates it...
void _CORE_semaphore_Initialize(CORE_semaphore_Control *the_semaphore, uint32_t initial_value)
Initializes the semaphore based on the parameters passed.
static __inline__ Semaphore_Control * _Semaphore_Allocate(void)
Allocates a semaphore control block from the inactive chain of free semaphore control blocks...
uint64_t Priority_Control
The thread priority control.
static __inline__ Status_Control _MRSP_Initialize(MRSP_Control *mrsp, const Scheduler_Control *scheduler, Priority_Control ceiling_priority, Thread_Control *executing, bool initially_locked)
Initializes a MrsP control.
RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority(rtems_attribute attribute_set)
Checks if the priority attribute is enabled in the attribute_set.
Thread queue context for the thread queue methods.
uint32_t rtems_name
This type is used to represent a Classic API object name.
static __inline__ const Scheduler_Control * _Thread_Scheduler_get_home(const Thread_Control *the_thread)
Gets the home scheduler of the thread.
CORE_ceiling_mutex_Control Mutex
void _Objects_Initialize_information(Objects_Information *information)
Initializes the specified objects information.
static __inline__ void _CORE_mutex_Set_owner(CORE_mutex_Control *the_mutex, Thread_Control *owner)
Sets the owner of the mutex.
static __inline__ void _Thread_Resource_count_increment(Thread_Control *the_thread)
Increments the thread's resource count.
CORE_recursive_mutex_Control Recursive
The plain recursive mutex.
Inlined Routines Associated with the Manipulation of the Scheduler.
#define RTEMS_INHERIT_PRIORITY
This attribute constant indicates that the Classic API Semaphore object shall use the Priority Inheri...
static __inline__ void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Thread_queue_Control Wait_queue
The thread queue present in all other variants.
static bool rtems_is_name_valid(rtems_status_code name)
Returns true, if the specified object name is valid, otherwise returns false.
#define RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
This attribute constant indicates that the Classic API Semaphore object shall use the Multiprocessor ...
static __inline__ Status_Control _CORE_ceiling_mutex_Set_owner(CORE_ceiling_mutex_Control *the_mutex, Thread_Control *owner, Thread_queue_Context *queue_context)
Sets the owner of the ceiling mutex.
This status code indicates that a specified number was invalid.
#define RTEMS_COUNTING_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore object shall be a counting semaphore...
Objects_Control Object
The object management portion of a semaphore instance.
static __inline__ struct _Thread_Control * _Thread_Get_executing(void)
Returns the thread control block of the executing thread.
#define RTEMS_PRIORITY
This attribute constant indicates that the Classic API object shall manage blocking tasks using the t...
uint32_t rtems_task_priority
%
rtems_status_code rtems_semaphore_create(rtems_name name, uint32_t count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, rtems_id *id)
Creates a semaphore with the specified properties and returns its identifier.
This status code indicates successful completion.
#define RTEMS_SIMPLE_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore object shall be a simple binary sema...
static __inline__ void _Objects_Open(Objects_Information *information, Objects_Control *the_object, Objects_Name name)
Places the_object control pointer and object name in the Local Pointer and Local Name Tables...
Classic Semaphore Manager Implementation.
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
#define RTEMS_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore object shall be a proper binary sema...
Classic Status Implementation.
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
CORE_mutex_Control Mutex
The plain non-recursive mutex.
static __inline__ void _Semaphore_Free(Semaphore_Control *the_semaphore)
Frees a semaphore control block to the inactive chain of free semaphore control blocks.
static __inline__ void _CORE_ceiling_mutex_Initialize(CORE_ceiling_mutex_Control *the_mutex, const Scheduler_Control *scheduler, Priority_Control priority_ceiling)
initializes a ceiling mutex.
static __inline__ void _Thread_queue_Context_clear_priority_updates(Thread_queue_Context *queue_context)
Clears the priority update count of the thread queue context.
This status code indicates that a specified address was invalid.
uint32_t rtems_attribute
This type is used to represent Classic API attributes.
#define RTEMS_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore object shall use the Priority Ceilin...
This status code indicates that the item has not been initialized.
Classic Attributes Implementation.
Objects_Id rtems_id
Values of this type identify an RTEMS object.
System State Handler API.
RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Clear(rtems_attribute attribute_set, rtems_attribute mask)
Clears the requested new_attributes in the attribute_set passed in.
CORE_semaphore_Control Semaphore
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
static __inline__ void _CORE_mutex_Acquire_critical(CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context)
Acquires the mutex critical.
Objects_Information _Semaphore_Information
The Classic Semaphore objects information.
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
static __inline__ void _Thread_queue_Destroy(Thread_queue_Control *the_thread_queue)
Destroys the thread queue.
This status code indicates that an object name was invalid.
union Semaphore_Control::@8 Core_control
#define RTEMS_GLOBAL
This attribute constant indicates that the Classic API object shall be a global resource in a multipr...
Semaphore_Variant
Classic semaphore variants.
static __inline__ void _CORE_recursive_mutex_Initialize(CORE_recursive_mutex_Control *the_mutex)
Initializes a recursive mutex.
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Classic Tasks Manager Implementation.