Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Operating System Questions 14) Fill in the three blanks in the following such th

ID: 3861215 • Letter: O

Question

Operating System Questions

14) Fill in the three blanks in the following such that two processes executing the code cannot enter the critical section at the same time. key is a local Boolean variable. The swap function swaps the contents of the two arguments.

do {
key = ______________;

while (key == FALSE) Swap (&lock, &key);

/* critical section */

lock = _____________;

/* remainder section */ } while (TRUE);

lock is a shared Boolean variable initialized to ___________.

15) signal(mutex) without a corresponding wait(mutex) on a binary semaphore mutex can potentially lead to a deadlock. [ TRUE / FALSE ]

16) A spinlock initialized to a positive integer can never acquire a negative value.
[ TRUE / FALSE ]

17) Consider two processes P0 and P1 executing the following code segments. The two processes are not allowed to be inside their critical sections at the same time. A and B are two semaphores initialized to 1.

P0

P1

wait(A);

wait(B);

/* critical section */

signal(B); signal(A);

wait(B);

wait(A);

/* critical section */

signal(A); signal(B);

a) Under what conditions can this synchronization procedure lead to a deadlock?

b) How can the possibility of a deadlock be eliminated by changing the order of the wait and/or signal statements? Any change you make should not enable the two processes to enter their critical sections concurrently.

c) How can the possibility of a deadlock be eliminated by changing the initialization values of the semaphores? Any change you make should not enable the two processes to enter their critical sections concurrently.

P0

P1

wait(A);

wait(B);

/* critical section */

signal(B); signal(A);

wait(B);

wait(A);

/* critical section */

signal(A); signal(B);

Explanation / Answer

Question 14:

do {
key = ____FALSE__________;

while (key == FALSE) Swap (&lock, &key);

/* critical section */

lock = FALSE_____________;

/* remainder section */ } while (TRUE);

lock is a shared Boolean variable initialized to __FALSE_________.

15) signal(mutex) without a corresponding wait(mutex) on a binary semaphore mutex can potentially lead to a deadlock

Answer: Its true with out binary semaphore mutex can lead to deadlock.