RTOS

Linux OS Topics
Post Reply
SukhdeepMankoo
Lieutenant
Lieutenant
Posts: 92
Joined: Tue Oct 27, 2009 7:50 pm

RTOS

Post by SukhdeepMankoo » Mon Jun 07, 2010 1:39 pm

hi ,
have u ever worked on RTOS?
I have doubts. kindly help to get rid of dilemma.

1) what is the difference between signal and event?
2) what is the difference between mutex and binary semaphore?

i have searched on net, but failed to clear doubts.
Can u help me?

Thanks.
Sukhdeep Singh.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: RTOS

Post by Neo » Tue Jun 08, 2010 12:13 am

I learned the Unix concepts under system programming/Inter process communication (IPC) quite a long ago that covered all these concepts in Operating Systems. I have searched the net and chosen the following answers as the best for you.
1) what is the difference between signal and event?
A signal is according to the Unix terminology a notification sent to a process that will interrupt that process. In order to catch a signal a process must have a signal handler.

An event is an inter task signalling mechanism which can be used to send/receive/pend for an event.
2) what is the difference between mutex and binary semaphore?
A mutex is essentially a binary semaphore, but with the additional property that it is logically "owned" by the executable entity (whether process or thread) that locked it. This property improves code structuring and allows some useful optimizations. You can't lock a mutex in one thread and then unlock it in another. You can, however, lock a binary semaphore in one thread and unlock it in another, because while a binary semaphore may be "locked" or "unlocked", it is never "owned".

Another definition is as follows.
A mutex is a binary semaphore that usually incorporates extra features, such as ownership, priority inversion protection or recursivity. The differences between mutexes and semaphores are that semaphores are operating system dependent, though mutexes are implemented by specialized and faster routines. Mutexes are meant to be used for mutual exclusion (post/release operation is restricted to thread that called pend/acquire) only and binary semaphores are meant to be used for event notification (post-ability from any thread) and mutual exclusion.
I recommend you to read System Programming/Inter Process Communication (based on UNIX which is the OS that introduced most of these concepts) to get a clear idea of these concepts. http://en.wikipedia.org/wiki/Inter-proc ... munication has some information. I referred the book "Operating Systems - Stallings" that covers all these concepts.
Post Reply

Return to “Linux”