⏪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);
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);
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⏩
- What is an Operating System ?
- Discuss the structure off OS ?
- Explain type of OS?
- Explain Function of OS?
- Explain OS Services ?
- What do mean by system call ?List different type ofsystem call available ?
- what is process ? and Characteristics ?
- What is different process state? explain the same in details?
- write short note on user level and kernal level threads?
- explain what is thread and its type ?
- explain scheduler ? (short term,medium term,and long term)
- state and explain scheduling criteria ?
- Explain scheduling algorithm ? [ FCFS,SJF,PRIORITY,ROUND ROBINE.]
- What is process synchronization ? explain critical section problem and race condition ?
- what is Race Condition ?
- what is critical section problem?
- explain classical problem of synchronization?
- explain bounded - buffer problem?
- explain reader - writer problem ?
- explain Dining Philosophers Problem ?
- explain semaphores ? its type ?
- What is deadlock ?
- What are the 4 condition to produce deadlock ?
- explain methods of handling deadlock ?
- explain in detail deadlock prevention ?
- write short note on deadlock avoidance ?
- explain deadlock detection ?
- explain Banker algorithm with example ?
- What are memory management ?
- what is contiguous memory allocation and non - contiguous memory allocation ?
- explain concept of paging with neat diagram?
- differentiate contiguous and non - contiguous memory allocation ?
- explain in details various partitioning memory management?
- explain the concept of Segmentation ?
- what is Thrashing explain in details ?
0 Comments