Keil Logo

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 1, 2007


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.