Operating System CS Thinking Example 2
Follow the full solution, then compare it with the other examples linked below.
Example 2
mediumExplain how an operating system allows multiple programs to run at the same time, even on a single-core CPU.
Solution
- 1 Step 1: The OS uses time-slicing (multitasking) โ it rapidly switches between programs, giving each a tiny slice of CPU time (e.g., a few milliseconds).
- 2 Step 2: The switching happens so fast that it appears simultaneous to the user, even though only one program runs at any instant on a single core.
- 3 Step 3: The OS scheduler decides which program runs next based on priority, fairness, and whether a program is waiting for input (I/O). Programs waiting for I/O do not need CPU time.
Answer
The OS uses time-slicing: rapidly switching between programs so fast that it appears simultaneous. A scheduler manages priorities.
Process scheduling is a core OS function. Without it, one program would monopolise the CPU while others froze. Modern OSes handle hundreds of processes this way.
About Operating System
System software that manages hardware resources (processor, memory, storage, devices) and provides services for application programs. The operating system acts as the intermediary between the user and the hardware, handling tasks like multitasking, file management, and device communication.
Learn more about Operating System โMore Operating System Examples
Example 1 easy
What is an operating system and name three things it manages.
Example 3 mediumExplain why you need device drivers and what happens when you plug in a new printer without the corr
Example 4 hardExplain the concept of user permissions in an operating system. Why does a school network restrict w