4/24/08

Explain Synchronization with Mutex, Events, Semaphores, Critical Sections.

Mutex
can be owned by a single thread at a time. all other will wait till that thread owns.
once released others can own and access the resources owned by first thread.


Semaphores:

Allows only a limited no. of threads to access protected resources.
Multiple threads can own it at a time.
Can have initial count and max count.
Initially initial count is equal to max. as owns by a thread it is decremented,
once it is zero, no more threads are allowed to access resources.

Critical Sections:
same as Mutex, can be owned by one thread at a time. can work withing process.
while mutex can work across process.


Events:
if one wants to alert, threads of some action is occuring.
SetEvent is called to signal a state to all the threads waiting for it.
PulseEvent used to quickly set-reset signalse.
These can be autoreset or manual reset events.
if manualreset =fasle( auto) will created and call setevent and changed to non signaled state.
if initialstate =true created and sets to signaled state

No comments: