In: Computer Science
Which of the following is true?
Select one:
a. No deadlock implies no starvation;
b. Starvation implies deadlock.
c. No starvation implies no deadlock;
d. Deadlock doesn’t imply starvation;
Which of the following indicates that Pi can enter the critical section in Peterson’s solution?
Select one:
a. flag[j] == true or turn == i
b. flag[j] == true and turn == j
c. flag[j] == false or turn == j
d. flag[j] == false or turn == i
Assume the binary variable lock is initialized to be 0, which of the following can be an implementation of the entry section to solve the critical-section problem?
Select one:
a. none of the other answers
b. both A and B
c. while (test and set(&lock)), do nothing;
d. while (compare and swap(&lock, 0, 1) != 0), do nothing;
Under which of the following contention loads does traditional synchronization become faster than CAS-based synchronization?
Select one:
a. none of the other answers
b. high contention
c. moderate contention
d. uncontended
Which of the following is NOT true regarding conditional variable, e.g. x?
Select one:
a. The x.signal() operation resumes exactly one suspended process
b. x.wait() means that the process invoking this operation is suspended until another process invokes x.signal()
c. If no process is suspended, then the signal() operation still affects the state of the semaphore
d. The only operations that can be invoked on a condition variable are wait() and signal()
Which of the following is true?
Select one:
a. No deadlock implies no starvation; -- TRUE
b. Starvation implies deadlock. -- FALSE
c. No starvation implies no deadlock; -- FALSE
d. Deadlock doesn’t imply starvation; --- FALSE
explanantion: deadlock implies starvation but
starvation doesn't imply deadlock and if there is no dead lock
there wont be any stravtion.
Which of the following indicates that Pi can enter the critical
section in Peterson’s solution?
b. flag[j] == true and turn == j
explanantion:
if there are two processes p1 and p2
p1:
wants to set the tunr to true
trun changed to true
and then result comes back as false as there are no busy
waiting
p2:
in mean while
p2 want to set the turn to true
but it reieceve result true as p1 set to true
p2 keeps waiting until p1 leaves
************************************************************************************************************************
Assume the binary variable lock is initialized to be 0, which of
the following can be an implementation of the entry section to
solve the critical-section problem?
Select one:
a. none of the other answers
explanation:
beacuse both c and d are correct
c. while (test and set(&lock)), do nothing;
d. while (compare and swap(&lock, 0, 1) != 0), do
nothing;
this type od implementation is called mutal exlustion
************************************************************************************************************************
Under which of the following contention loads does
traditional synchronization become faster than CAS-based
synchronization?
Select one:
d. uncontended
explanation:
atomic instructions makes CAS slow than traditional when
thereis
no contection
************************************************************************************************************************
Which of the following is NOT true regarding conditional
variable, e.g. x?
Select one:
a. The x.signal() operation resumes exactly one suspended process--TRUE
b. x.wait() means that the process invoking this operation is suspended until another process invokes x.signal()---TRUE
c. If no process is suspended, then the signal() operation still affects the state of the semaphore---FALSE
d. The only operations that can be invoked on a condition variable are wait() and signal() ---TRUE