Chapter 5 Real-Time Kernel
229
Allow a task to synchronize with either an ISR or a task
Gain exclusive access to a resource
Signal the occurrence of an event
Note that semaphores must be created before they are used. This function
cannot be called from an ISR.
Return
A pointer to the event control block allocated to the semaphore.
If no event control blocks are available, a NULL pointer will be returned.
See Also
OSSemPend, OSSemPost
OSSemPend
Purpose
To list a task on the pending list for the semaphore.
Syntax
Void OSSemPend (OS_Event *pevent, unsigned long timeout, unsigned char
*err);
where,
pevent
is a pointer to the semaphore. This pointer is returned to your
application when the semaphore is created.
timeout
is used to allow the task to resume execution if the semaphore is not
acquired within the specified number of clock ticks. A
timeout
value of 0
indicates that the task desires to wait forever for the semaphore. The maximum
timeout
can be 65535 clock ticks.
err
is a pointer to a variable which will be sued to hold an error code.
OSSemPend sets *err to either:
(1) OS_NO_ERR, if the semaphore is available.
(2) OS_TIMEOUT, if a timeout occurred.
Example
OSSemPend (DispSem, 0, &err);
Description
This function is used when a task desires to gain exclusive access to a resource,
to synchronize its activities with an Interrupt Service Routine (ISR), or to wait
until an event occurs.
If a task calls OSSemPend and the value of the semaphore is greater than zero,
then OSSemPend will decrement the semaphore count and return to its caller.
However, if the value of the semaphore is less than or equal to zero,
OSSemPend decrements the semaphore count and places the calling task in the
pending list for the semaphore. The task will thus wait until a task or an ISR
releases the semaphore or signals the occurrence of the event. In this case,
rescheduling occurs and the next highest priority task ready to run is given
control of the CPU. An optional timeout may be specified when pending for a
semaphore.
Note that semaphores must be created before they are used. This function
cannot be called from an ISR.
Return
None
See Also
OSSemCreate, OSSemPost
Содержание Optimus R
Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Страница 6: ......
Страница 8: ...2 C Programming Guide For Optimus S R...
Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Страница 24: ...18 C Programming Guide For Optimus S R...
Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...
Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...
Страница 238: ...232 C Programming Guide For Optimus S R...