Keil™, An ARM® Company

Technical Support

RL-ARM: ACQUIRE/RELEASE OR BINARY SEMAPHORE IN RTX KERNEL


Information in this article applies to:

  • RL-ARM Version 3
  • MDK-ARM Version 3
  • ARTX166 any Version

QUESTION

Does the RTX kernel support binary semaphores?

Some RTOS has also a acquire and release command for semaphores. Is this available?

ANSWER

The 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 ALSO

Last Reviewed: Thursday, March 01, 2007


Did this article provide the answer you needed?
 
Yes
No
Not Sure