Recents in Beach

Classical Problem on Synchronization

Previous                                                          Next⏩




There are various types of problem which are proposed for synchronization scheme such as
·  Bounded Buffer Problem: 
                  This problem was commonly used to illustrate the power of synchronization primitives. In this scheme we assumed that the pool consists of ‘N’ buffer and each capable of holding one item. The ‘mutex’ semaphore provides mutual exclusion for access to the buffer pool and is initialized to the value one. The empty and full semaphores count the number of empty and full buffer respectively. The semaphore empty is initialized to ‘N’ and the semaphore full is initialized to zero. This problem is known as procedure and consumer problem. The code of the producer is producing full buffer and the code of consumer is producing empty buffer. The structure of producer process is as follows:

do {
produce an item in nextp
. . . . . . . . . . . .
Wait (empty); 
Wait (mutex);
. . . . . . . . . . .
add nextp to buffer
. . . . . . . . . . . .
Signal (mutex); 
Signal (full);

}

While (1);

The structure of consumer process is as follows : 


do {
Wait (full); 
Wait (mutex);
. . . . . . . . . . .
Remove an item from buffer to nextc
. . . . . . . . . . .
Signal (mutex);
 Signal (empty);
. . . . . . . . . . . .
Consume the item in nextc;
. . . . . . . .. . . .. .
} While (1);


·  Reader Writer Problem: 
                     In this type of problem there are two types of process are used such as Reader process and Writer process. The reader process is responsible for only reading and the writer process is responsible for writing. This is an important problem of synchronization which has several variations like .
The simplest one is referred as first reader writer problem which requires that no reader will be kept waiting unless a writer has obtained permission to use the shared object. In other words no reader should wait for other reader to finish because a writer is waiting.
The second reader writer problem requires that once a writer is ready then the writer performs its write operation as soon as possible.The structure of a reader process is as follows: 

Wait(mutex);
Read count++;
if (read count == 1) 
Wait (wrt);
Signal (mutex);
. . . . . . . . . . .
Reading is performed
. . . . . . . . . . .
Wait (mutex);
Read count --;
if (read count == 0) 
Signal (wrt);
Signal (mutex);

The structure of the writer process is as follows:

Wait (wrt);
Writing is performed;
 Signal (wrt);


· Dining Philosopher Problem:
                    Consider 5 philosophers to spend their lives in thinking & eating. A philosopher shares common circular table surrounded by 5 chairs each occupies by one philosopher. In the center of the table there is a bowl of rice and the table is laid with 6 chopsticks as shown in below figure.
           
         

When a philosopher thinks she does not interact with her colleagues. From time to time a philosopher gets hungry and tries to pickup two chopsticks that are closest to her. A philosopher may pickup one chopstick or two chopsticks at a time but she cannot pickup a chopstick that is already in hand of the neighbor. When a hungry philosopher has both her chopsticks at the same time, she eats without releasing her chopsticks. When she finished eating, she puts down both of her chopsticks and starts thinking again. This problem is considered as classic synchronization problem. According to this problem each chopstick is represented by a semaphore. A philosopher grabs the chopsticks by executing the wait operation on that semaphore. She releases the chopsticks by executing the signal operation on the appropriate semaphore. The structure of dining philosopher is as follows:
do{
Wait ( chopstick [i]);
Wait (chopstick [(i+1)%5]);
. . . . . . . . . . . . .
Eat
. . . . . . . . . . . . .
Signal (chopstick [i]);
Signal (chopstick [(i+1)%5]);
. . . . . . . . . . . . .
Think
. . . . . . . . . . . . .
} While (1);


Previous                                                          Next⏩

  1. What is an Operating System ?
  2. Discuss the structure off OS ?
  3. Explain type of OS?
  4. Explain Function of OS?
  5. Explain OS Services ?
  6. What do mean by system call ?List different type ofsystem call available ?

  1. what is process ? and Characteristics ?
  2. What is different process state? explain the same in details?
  3. write short note on user level and kernal level threads?
  4. explain what is thread and its type ?
  5. explain scheduler ? (short term,medium term,and long term)
  6. state and explain scheduling criteria ?
  7. Explain scheduling algorithm ? [ FCFS,SJF,PRIORITY,ROUND ROBINE.]    

  1. What is process synchronization ? explain critical section problem and race condition ?
  2. what is Race Condition ?
  3. what is critical section problem?
  4. explain classical problem of synchronization?
  5. explain bounded - buffer problem?
  6. explain reader - writer problem ?
  7. explain Dining Philosophers Problem ?
  8. explain semaphores ? its type ?

  1.  What is deadlock ?
  2. What are the 4 condition to produce deadlock ?
  3. explain methods of handling deadlock ?
  4. explain in detail deadlock prevention ?
  5. write short note on deadlock avoidance ?
  6. explain deadlock detection ? 
  7. explain Banker algorithm with example ? 

Post a Comment

0 Comments