Transitionready → running pid:B - Process B dispatched to CPU
A
ready
burst: 9
B
running
burst: 8
Ready Queue
A
Waiting Queue
empty
🖥CPUBt=3
A
A.T1
Transitionrunning → running pid:B - Process B executed 1 time unit
A
ready
burst: 9
B
running
burst: 7
Ready Queue
A
Waiting Queue
empty
🖥CPUBt=4
A
A.T1
B
Transitionready → running pid:A - Process A dispatched to CPU
A
running
burst: 9
B
ready
burst: 7
Ready Queue
B
Waiting Queue
empty
🖥CPUAt=4
A
A.T1
B
Transitionrunning → terminated pid:A - Process A completed execution and terminated
B
ready
burst: 7
Ready Queue
B
Waiting Queue
empty
🖥CPUidlet=5
A
A.T1
B
A
Transitionrunning → terminated pid:B - Process B completed execution and terminated
Ready Queue
empty
Waiting Queue
empty
🖥CPUidlet=13
A
A.T1
B
A
B
Key Takeaways
✓ Processes have independent memory and resources, while threads share the process's resources but have separate execution contexts.
This difference is often abstract in code but becomes clear when watching resource allocation and scheduling side-by-side.
✓ Threads are scheduled independently but run within the context of their parent process, allowing lightweight concurrency.
Seeing threads enter ready and running states within the same process clarifies how they differ from full processes.
✓ CPU scheduling switches between processes and threads, demonstrating context switching and resource sharing in action.
Visualizing scheduling decisions helps understand how the OS manages multitasking and resource allocation.
Practice
(1/5)
1. Trace the sequence of page faults when using the FIFO algorithm with 3 frames for the reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. How many page faults occur?
Hint: FIFO faults count equals number of unique pages plus evictions [OK]
Common Mistakes:
Counting hits as faults
Misordering evictions in FIFO
Forgetting to update frames after eviction
2. Why does increasing the frequency of context switches beyond a certain point degrade overall system performance?
medium
A. Because saving and restoring CPU registers is a costly operation that consumes CPU cycles
B. Because the scheduler runs out of processes to schedule
C. Because the MMU has to reload page tables more frequently
D. Because the CPU cache is flushed automatically on every context switch
Solution
Step 1: Identify overhead of context switch
Saving/restoring CPU registers and PCB updates consume CPU time, causing overhead.
Step 2: Scheduler availability
The scheduler can always select processes; running out is not a cause of performance degradation.
Step 3: MMU and page tables
MMU page table reloads happen on address space switches, but not necessarily on every context switch.
Step 4: CPU cache behavior
CPU cache is not flushed automatically on every context switch; cache invalidation is more complex.
Final Answer:
Option A -> Option A
Quick Check:
Context switch overhead is mainly CPU cycles spent saving/restoring registers.
Hint: More switches -> more register save/restore overhead -> slower system [OK]
Common Mistakes:
Believing scheduler runs out of processes
Assuming MMU reloads page tables every switch
Thinking CPU cache flushes on every context switch
3. Which of the following statements about the convoy effect in FCFS scheduling is INCORRECT?
medium
A. The convoy effect occurs when a long process delays all subsequent shorter processes
B. The convoy effect can be mitigated by introducing preemption in the scheduling algorithm
C. The convoy effect causes the average waiting time to always be minimal in FCFS
D. The convoy effect leads to poor CPU utilization and increased waiting times
Solution
Step 1: Analyze each statement
A is correct; long processes delaying short ones is the convoy effect. B is correct; preemption can reduce the convoy effect. C is incorrect; the convoy effect increases average waiting time, not minimizes it. D is correct; convoy effect can cause poor CPU utilization and longer waits.
Step 2: Identify the incorrect statement
Only The convoy effect causes the average waiting time to always be minimal in FCFS falsely claims minimal average waiting time due to the convoy effect.
Final Answer:
Option C -> Option C
Quick Check:
Convoy effect worsens waiting time, not improves it.
Hint: Convoy effect -> longer waits, not shorter
Common Mistakes:
Assuming convoy effect improves waiting time
Ignoring preemption as a mitigation
Misunderstanding convoy effect impact on CPU utilization
4. If a system using FCFS scheduling introduces a mix of I/O-bound and CPU-bound processes arriving at different times, how does this affect the convoy effect and waiting times, and what strategy could reduce the negative impact?
hard
A. The convoy effect disappears because I/O-bound processes run first, so waiting times decrease automatically
B. The convoy effect worsens as CPU-bound processes block I/O-bound ones, increasing waiting times; introducing preemption can help
C. Waiting times remain unchanged because FCFS ignores process type and arrival time
D. The convoy effect is irrelevant in mixed workloads since I/O-bound processes do not use the CPU
Solution
Step 1: Understand process types in FCFS
FCFS schedules strictly by arrival order, regardless of process type.
Step 2: Analyze impact of mixed workloads
CPU-bound processes arriving first can delay I/O-bound processes, worsening the convoy effect and increasing waiting times.
Step 3: Mitigation strategy
Introducing preemption or priority scheduling can reduce waiting times for I/O-bound processes by allowing them to run sooner.
Step 4: Evaluate options
A is incorrect; convoy effect does not disappear automatically. B is correct; convoy effect worsens and preemption helps. C is incorrect; waiting times do change due to process mix. D is incorrect; convoy effect is relevant because all processes compete for CPU.
Final Answer:
Option B -> Option B
Quick Check:
Mixed workloads worsen convoy effect; preemption mitigates it.
Assuming I/O-bound processes run first automatically
Believing waiting times don't change with process mix
Ignoring convoy effect in mixed workloads
5. If a system uses preemptive SJF scheduling but the burst times of processes are not known in advance and must be estimated, which challenge is most likely to affect scheduling accuracy?
hard
A. Incorrect burst time estimates can cause frequent unnecessary preemptions
B. The scheduler will always pick the wrong process due to estimation errors
C. Non-preemptive scheduling must be used instead to avoid errors
D. Starvation is eliminated because estimates prevent preemption
Solution
Step 1: Understand burst time estimation impact
Estimations can be inaccurate, causing the scheduler to preempt based on wrong assumptions.
Step 2: Analyze consequences
Frequent unnecessary preemptions increase overhead and reduce efficiency.
Step 3: Why other options are incorrect
B: Scheduler won't always pick wrong process; estimates can be close. C: Non-preemptive scheduling is a design choice, not forced by estimation. D: Starvation is not eliminated by estimates; it depends on scheduling policy.
Final Answer:
Option A -> Option A
Quick Check:
Estimation errors cause scheduling inefficiency via unnecessary preemptions.
Hint: Bad burst time estimates cause too many preemptions in preemptive SJF [OK]
Common Mistakes:
Assuming estimates always cause wrong scheduling
Believing estimation removes starvation
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.