PDK API Guide for J721E
SemaphoreP.h File Reference

Introduction

Semaphore module for the RTOS Porting Interface.

============================================================================

Semaphores can be counting semaphores or binary semaphores. Counting semaphores keep track of the number of times the semaphore has been posted with post functions. This is useful, for example, if you have a group of resources that are shared between tasks. Such tasks might call pend() to see if a resource is available before using one. A count of zero for a counting semaphore denotes that it is not available. A positive count denotes how many times a SemaphoreP_pend can be called before it is blocked (or returns SemaphoreP_TIMEOUT).

Binary semaphores can have only two states: available (count = 1) and unavailable (count = 0). They can be used to share a single resource between tasks. They can also be used for a basic signalling mechanism, where the semaphore can be posted multiple times. Binary semaphores do not keep track of the count; they simply track whether the semaphore has been posted or not.


Go to the source code of this file.

Semaphore status code

#define SemaphoreP_OK   (0)
 
#define SemaphoreP_FAILURE   (-(int32_t)1)
 
#define SemaphoreP_TIMEOUT   (-(int32_t)2)
 
#define SemaphoreP_UNSUPPORTED   (-(int32_t)3)
 
typedef int32_t SemaphoreP_Status
 Status codes for SemaphoreP APIs. More...
 

Mode of Semaphore

#define SemaphoreP_Mode_COUNTING   (0x0U)
 
#define SemaphoreP_Mode_BINARY   (0x1U)
 
typedef uint32_t SemaphoreP_Mode
 Mode of the semaphore. More...
 

Data Structures

struct  SemaphoreP_Params
 Basic SemaphoreP Parameters. More...
 

Macros

#define SemaphoreP_WAIT_FOREVER   (~((uint32_t)0U))
 Wait forever define. More...
 
#define SemaphoreP_NO_WAIT   ((uint32_t)0U)
 No wait define. More...
 

Typedefs

typedef void * SemaphoreP_Handle
 Opaque client reference to an instance of a SemaphoreP. More...
 

Functions

SemaphoreP_Handle SemaphoreP_create (uint32_t count, const SemaphoreP_Params *semParams)
 Function to create a semaphore. More...
 
SemaphoreP_Status SemaphoreP_delete (SemaphoreP_Handle semPhandle)
 Function to delete a semaphore. More...
 
void SemaphoreP_Params_init (SemaphoreP_Params *semParams)
 Initialize params structure to default values. More...
 
SemaphoreP_Status SemaphoreP_pend (SemaphoreP_Handle semPhandle, uint32_t timeout)
 Function to pend (wait) on a semaphore. More...
 
SemaphoreP_Status SemaphoreP_post (SemaphoreP_Handle semPhandle)
 Function to post (signal) a semaphore. More...
 
SemaphoreP_Status SemaphoreP_postFromClock (SemaphoreP_Handle semPhandle)
 Function to post (signal) a semaphore from an ClockP function. More...
 
SemaphoreP_Status SemaphoreP_postFromISR (SemaphoreP_Handle semPhandle)
 Function to post (signal) a semaphore from an ISR. More...
 
int32_t SemaphoreP_getCount (SemaphoreP_Handle semPhandle)
 Function to return the count of a semaphore. More...
 
SemaphoreP_Status SemaphoreP_reset (SemaphoreP_Handle semPhandle)
 Function to clear a semaphore for reuse. More...