CPU Scheduling

Answer & solution
Answer: B (no official key was published)
Step through it (8 steps)
1. Approach. At each arrival compare remaining service, not original burst lengths. Draw the execution intervals and count only the intervals after P2 arrives during which it is ready but not running.
2. Derivation and interpretation. P1 runs from 0 to 20: at P2's arrival at 15, P1 has only 5 units left versus P2's 25. P2 runs 20–30, leaving 15; P3 then arrives with 10 and runs 30–40. P2 resumes at 40. When P4 arrives at 45, P2 has 10 left versus P4's 15, so P2 continues until 55. Its waiting intervals are 15–20 and 30–40, totaling 5+10=15 (B). Equivalently completion−arrival−execution=55−15−25=15.