ARM Technical Support Knowledge Articles

ACQUIRE/RELEASE OR BINARY SEMAPHORE IN RTX KERNEL

Applies to: RealView Real-Time Library

Answer


Information in this article applies to:


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

Article last edited on: 2007-03-01 02:05:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential