263 views
2 2 votes

Which of the following statements are correct?

  1. With kernel-level threads, if one thread of a process blocks, all the threads of that process will also be blocked.
     
  2. A lock implementation should always block instead of spin if it will always be used only on a uniprocessor.
     
  3. On a multiprocessor, a lock implementation should spin instead of block if it is known that the lock will be available before the time required for a context switch.
     
  4. Periodically yielding the processor while spin-waiting reduces the amount of wasted time to be proportional to the duration of a time slice.

1 Answer

1 1 vote

Statement (A) is incorrect.
Kernel-level threads are individually known to the operating system.
If one kernel-level thread blocks, another runnable thread of the same process can still be scheduled.

Statement (B) is correct.
On a uniprocessor, a thread that is spinning prevents the thread holding the lock from running.
Blocking allows the lock holder to be scheduled and release the lock.

Statement (C) is correct.
On a multiprocessor, the lock holder may be executing on another processor.
If the lock will become available sooner than the cost of blocking and performing a context switch, spinning is preferable.

Statement (D) is incorrect.
Yielding avoids spinning for an entire time slice.
The resulting wasted time is related to the cost of context switching, not the full duration of the scheduling time slice.

Answer:
Position:
Show:

Related questions

1 1 vote
1 1 answer
259
259 views
GO Classes asked Jul 17
259 views
Which of the following statements about context switching are correct?When switching between two threads, the registers, stack pointer, and program counter of the outgoin...
3 3 votes
1 1 answer
203
203 views
GO Classes asked Jul 17
203 views
Which of the following statements are correct?Threads that are part of the same process share the same stack pointer. Threads that are part of the same process share the ...
2 2 votes
1 1 answer
180
180 views
GO Classes asked Jul 17
180 views
Which of the following statements are correct?Threads belonging to the same process use a common stack. Threads belonging to the same process can use the same valid TLB e...
8 8 votes
3 3 answers
4.5k
4.5k views
_jerry asked Jan 26, 2018
4,487 views
S1: Context Switching occurs only in kernel mode. :TRUES2: Context Switching in user mode is faster as compared to context switching in kernel mode. : TRUEIf Context Swit...