| |||||
Technical Support Support Resources
Product Information | RL-ARM: ACQUIRE/RELEASE OR BINARY SEMAPHORE IN RTX KERNELInformation in this article applies to:
QUESTIONDoes the RTX kernel support binary semaphores? Some RTOS has also a acquire and release command for semaphores. Is this available? ANSWERThe RTX kernel supports counting semaphores. A binary semaphore is just a reduction of a counting semaphore that supports just one bit. Therefore you may simply use a counting semaphore instead of a binary semaphore. For example:
os_sem_init (semaphore1, 1);
void protected_io (void) {
os_sem_wait (semaphore1, 0xFFFF); // get the token
// Read or write to shared resource...
.
.
.
os_sem_send (semaphore1); // give the token back
}
Semaphore "acquire" and "release" can be directly mapped to a binary semphore as shown below: os_sem_wait (semaphore1, 0xffff); // equivalent to acquire os_sem_send (semaphore1); // equivalent to release MORE INFORMATION
SEE ALSOLast Reviewed: Thursday, March 01, 2007 | ||||
| |||||