I have the following basic semaphore question, for which I was not
able to find an answer in the VxWorks manual :
--> what happens if a task takes a sem which it has already taken, or if
a task gives a sem which has not been taken?
Thanks!!
Regards,
Horace
Mutex (semMlib semaphore) - Can be taken recursively by a task. For every
semTake, a corresponding semGive must be present. semGive can only be
done from the task that performed the semTake.
Counting & Binary semaphores - Are not sensitive as to which task performs
the semTake or semGive. Task 1 may perform a semTake, while task 2
performs
corresponding semGive.
For more info, read the manuals, it is all there !
Cheers,
Manuel
"Horace Yu" <hora...@sympatico.ca> wrote in message
news:3BA81679...@sympatico.ca...
I am using a binary sem. I know it doesn't matter which task do the Take
or Give. But what happens if the same task tries to semTake a second time
without someone else semGive; or if the same task does a semGive without
someone else (or itself) semTake it?
Thanks again.
Regards,
Horace
If you try to take and the sem is empty, the task blocks for the time
specified in the semTake function call, or until some other task gives the
sem,
whichevewr comes first.
If you give the sem and it is already full, nothing happend. It remains
full.
There are other situations for counting semaphores, mutex semaphores, etc.
The details are in the reference manual, under the functions in question.
One caveat: make sure that you decide which type of sem you want.
There are manny variations on the theme available.
Speaking only for myself,
Joe Durusau
"Horace Yu" <hora...@sympatico.ca> wrote in message
news:3BA899D7...@sympatico.ca...