Pumpkin, Inc.

Pumpkin User Forums

How to ensure that BinSem is empty(free)

If you can't make Salvo do what you want it to do, post it here.

How to ensure that BinSem is empty(free)

Postby luben » Tue Jan 02, 2001 6:31 am


If I want to signal a binary semaphore with OSSignalBinSem(sem) and the semaphore is filled (still the other task didn't cleared it with OS_WaitBinSem()) how I can ensure that it's free. Because you don't have functions like OSStatBinSem(), what I can figure out is:

1. while (OSSignalBinSem(sem))

this will check if the semaphore is empty with frequency depend on <time> - if the semaphore is not empty the function will return error and the loop will continue. This even could be extended with something like timeout if I count how many times I tried to signal the semaphore.

2. To add one additional semaphore, that ensures that resources are free. If this semaphore is not signaled - I can't signal my semaphore too. I took this idea from the manual (PORT control)


This will free the software from many conflicts and even I could implement timeout for successful operation very easy.

The disadvantage of 2 is that it consumes more RAM (1 event more) and maybe more ROM and uP time.

My question is - wich is the Salvo recommended way of signaling semaphores. Is there other way to check if the semaphore is free, then to do <while> construction?


Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: How to ensure that BinSem is empty(free)

Postby Salvo Tech Support » Wed Jan 03, 2001 8:21 am

Hi Luben.

There isn't really a good way to obtain the samaphore's value in v2.1.

v2.2 will contain OSRtnBinSem/Msg/MsgQ/Sem services.

Salvo Technical Support
Please request all tech support through the Forums.
Salvo Tech Support
Posts: 173
Joined: Sun Nov 19, 2000 12:00 am

Re: How to ensure that BinSem is empty(free)

Postby aek » Wed Jan 03, 2001 12:02 pm

Actually, one can use the following macros (see salvo.h) to return binary semaphore, message and semaphore values:



myBinSem6 = OSECB_BIN_SEM(6);

v2.2 will contain functions to do the same, plus support for message queues. The advantage to using functions is in ROM usage -- it's just a function call with a single argument, whereas the macros expand out to something bigger.

NOTE: these macro names will change under v2.2.

[This message has been edited by aek (edited January 03, 2001).]

Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests