semaphores or mutex impl

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
does anyone now of any helpful resources (online or print) for implementing
critical section semaphores or mutexes for a preemptive multi-tasking
system.

thanks in advance,
bryan




Re: semaphores or mutex impl
Quoted text here. Click to load it

Jean Labrosse has documented the uC/OS realtime kernel in a book.  I
have the original "uC/OS The Real-Time Kernel", but I think he has out a
later book covering the uC/OS-II version.

In general for a single-processor system, the P (or wait) semaphore
operator will normally disable interrupts and determine if the semaphore
counter allows the current task to proceed.  If so, it decrements the
counter, reenables interrupts and returns.

If the counter is non-positive, the current task is then queued on the
semaphore, and a context switch is made to a ready task.

For the V (or signal) operator the system disables interrupts and
determines whether there are any tasks waiting on the semaphore.  If so,
it takes one such task and makes it ready to execute.  If that task has
a higher priority than the current task, a context switch is made to
activate it immediately.  If no tasks are waiting, the semaphore count
is incremented.

In general, the operation of semaphores is closely tied to the code to
do a context switch and change task status (suspended, ready).  Note
that if an interrupt routine does a V operation which makes a high
priority task ready, returning from the initial interrupt must cause a
context switch, rather than simply returning to the interrupted task.


Thad

Re: semaphores or mutex impl
On Mon, 14 Jul 2003 15:02:54 GMT, "Bryan Bullard"

Quoted text here. Click to load it

Tanenbaum's several operating systems book are pretty readily
found in print versions.  In fact, almost *any* operating
systems textbook will at least talk about the various issues and
propose some small samples for you to consider and look at.
You'll have to read between the lines for some of these, to
actually implement what you want.  But that's not very hard,
even with these more broad-brush textbooks.

If you want something concrete and easy to understand, track
down Douglas Comer's books -- most particularly, his first book
on XINU.  It's concrete, provides a complete but very simple
system easily understood (in C) and not just hand-waving, and is
pretty well organized for comprehension.

Jon


Re: semaphores or mutex impl

Quoted text here. Click to load it

Have you looked at the book "Operating System Design, The XINU Approach" by
Douglas Comer? My copy is a little old, published in 1984 (there is
probably a second, or third, edition). With all the books I have on this
subject, it is still one of my favorites.

Paul Scherf
MidStream Technologies
Bellevue, Washington

Site Timeline