Home › GATE CSE › computerscience › Operating Systems › STCF runs job A (100) at t=0, but at t=10 jobs B…
STCF runs job A (100) at t=0, but at t=10 jobs B (10) and C (10) arrive. What does STCF do?
Acontinues running A to completion (non-preemptive)
Bpreempts A and runs B (or C), since their remaining time is shorter
Cruns A and B in parallel on the same CPU
Daborts A and discards it
Answer & Solution
Correct answer: B. preempts A and runs B (or C), since their remaining time is shorter
1. STCF is PREEMPTIVE. At every scheduling decision (e.g. when a new job arrives), it compares the REMAINING time of the running job to the new jobs' run times.
2. At t=10: A has 90 remaining; B and C each have 10. So STCF PREEMPTS A and runs B (then C, then A).
3. Schedule: A runs 0-10, B 10-20, C 20-30, A 30-120.
4. Turnaround: A=120, B=20, C=30. Average = $(120+20+30)/3 \approx 56.7$.
5. Compare to non-preemptive SJF which would NOT have preempted A — A would have run 0-100, then B 100-110, then C 110-120 → avg = $(100+110+120)/3 = 110$ (same as FIFO!).
6. So STCF's preemption is key. Option A describes SJF, not STCF.
_Source: OSTEP Ch 7, §7.5 (STCF — preemption example), p. 5-6._
Related questions
On a MULTI-CORE system, a SPIN LOCK is generallyDisabling INTERRUPTS as a way to implement mutual exclusion on a single-CPU system isA LIVELOCK differs from a DEADLOCK in thatSuppose thread A acquires lock L1, then thread B acquires lock L2. Now A tries to acquire Without atomic hardware support, building a correct mutual-exclusion lock for $N \geq 2$ tA CRITICAL SECTION isLinux's `pthread_mutex_lock()` is typically implemented as a HYBRID:What is the PRIMARY problem with using a SPIN LOCK on a SINGLE-CPU uniprocessor system (wi