EmbLogic's Blog

Semaphore

Its a synchronization mechanism in which one process can access shared resource at one time and other processes are in a wait stage.Its used in synchronizing multiple processes.The processes are in a queue,when semaphore increments or when its greater than zero then all the process pops out of the queue and only one process enter the critical region,when a process enters the critical region it decrements semaphore and after process completion it exits increments and exits the semaphore.The increment operation is known as a “signal” and decrement operation is “wait”.

To make a semaphore,its variable should be greater the zero.To initialize a Semaphore 3 function definition are used :

1. kernel key=segmet(user key,no. of semaphores,666|IPC_CREAT);

2. semctl(kernel key,index,command,…(optional));

3. semop(kernel key,struct sembuf*sops,size of sops);

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>