228
"C" Programming Guide For Optimus S/R
OS_EXIT_CRITICAL
OSSemCreate
To ensure this, user can call this routine to disable interrupts prior to executing
the critical code, and then enable the interrupts when the critical code is done.
This function executes in about 5 CPU clock cycles.
OS_ENTER_CRITICAL and OS_EXIT_CRITICAL must be used in pairs.
Return
None
See Also
OS_EXIT_CRITICAL
Purpose
To enable the processor's interrupt.
Syntax
void OS_EXIT_CRITICAL (void);
OS_ENTER_CRITICAL ();
Example
/* user code */
OS_EXIT_CRITICAL();
This function executes in about 5 CPU clock cycles.
Description
OS_ENTER_CRITICAL and OS_EXIT_CRITICAL must be used in pairs.
Return
None
OS_ENTER_CRITICAL
See Also
Purpose
To create and initialize a semaphore.
Syntax
OS_EVENT *OSSemCreate (unsigned value);
where, OS_EVENT, a data structure to maintain the state of an event called an
Event Control Block (ECB), is defined as below.
typedef struct os_event {
unsigned char OSEventGrp;
unsigned char OSEventTbl[8];
long OSEventCnt;
void *OSEventPtr;
} OS_EVENT;
value is the initial value of the semaphore, which is allowed to be between 0
and 32767.
Example
DispSem = OSSemCreate (1);
Description
This function creates and initializes a semaphore. A semaphore is used to:
/* Group corresponding to tasks waiting for event to occur */
/* List of tasks waiting for event to occur */
/* Count of used when event is a semaphore */
/* Pointer to message or queue structure */
/* create Display semaphore */