Operating System (Short answers with brief explanation.)

Operating System (Short answers with brief explanation.)
only 5 questions requires brief explain.
Answer the following: ( all the questions requires brief answers like 2~4 lines are fine.)
1. Suppose a system implements threads in kernel. Can two threads in the same process synchronize using a kernel semaphore Explain. [4 points]
2. Consider the following codes of two processes sharing a variable turn that is initialized to 1. Do the processes satisfy all requirements of critical region solution (i.e., mutual exclusion, progress & bounded waiting) Explain. [6 points]
Process P0 Process P1
/* other code */
while (turn != 0){ } /* wait */
update(); /* critical region */
turn = 0;
/* other code */ /* other code */
while (turn != 1){ } /* wait */
update(); /* critical region */
turn = 1;
/* other code */

3. Suppose there are two processes – i and j, sharing variables turn and flag[2]. Consider the following code for process i. Process j has similar code.
do {
flag[i] = true;
while (flag[j]) {
if (turn == j) {
flag[i] = false;
while (turn == j); /* do nothing */
flag[i] = true;
}
}

critical_task(); /* critical region */

turn = j;
flag[i] = false;

other_tasks(); /* remainder section */
}while (true);
Explain whether the above solution satisfy the necessary conditions (mutual exclusion, progress & bounded waiting) of critical region problem. [7 points]
4. A counting semaphore can have any arbitrary integral value. A process using such semaphore does not block until a down() invoked by the process on the semaphore makes the value negative. A negative value of the counting semaphore indicates that many processes blocked on the semaphore. An up() on the semaphore will wakeup a blocked process if the value is still non-positive. Describe how such a counting semaphore can be implemented using only binary semaphores and ordinary machine instructions. You may also use simple integer variables and list data structure. [7 points]

5. Briefly explain a monitor construct. How does it achieve synchronization of processes [6 points]

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"