Operating Systems: CPU Scheduling Flashcards
What alternating cycle do almost all programs exhibit?
Almost all programs alternate between CPU number crunching (computation) and waiting for some kind of I/O.
Why is even a simple fetch from memory significant relative to CPU speeds?
Even a simple fetch from memory takes a long time compared to the rapid speed of CPU operations.
What happens to CPU cycles when a process waits for I/O?
CPU cycles used during I/O waiting are lost forever, representing wasted potential processing time.
How does CPU scheduling help when a process is waiting for I/O?
CPU scheduling allows another process to use the CPU while one is waiting for I/O, thereby making use of otherwise lost CPU cycles.
What is the main challenge in scheduling for an operating system?
The challenge is to make the overall system as “efficient” and “fair” as possible.
What factors must be considered given that efficiency and fairness are subjective?
The system must adapt to varying and dynamic conditions and may be influenced by shifting priority policies.
How is CPU utility maximized in a multiprogramming environment?
By overlapping CPU bursts with I/O bursts, ensuring the CPU is busy processing while other processes wait for I/O.
What is the CPU–I/O burst cycle in process execution?
Process execution consists of alternating cycles of a CPU burst (active processing) followed by an I/O burst (waiting for I/O).
What aspect of the CPU burst is of main concern in scheduling?
The distribution of CPU bursts is a main concern because it affects how efficiently processes are scheduled.
How are data transfers from disk to memory handled, and what does this imply for the CPU?
Data transfers are handled by the system bus, meaning the processor remains available to process data during disk I/O.
What is the role of the short-term scheduler?
The short-term scheduler selects which process in the ready queue should execute next and allocates the CPU. It is invoked frequently (every few milliseconds) and must be very fast.
What is the function of the long-term scheduler?
The long-term scheduler decides which processes should be brought into the ready queue and controls the degree of multiprogramming. It is invoked less frequently (every few seconds or minutes).
How are processes classified with respect to the long-term scheduler?
I/O-bound processes: Spend more time doing I/O than computations, resulting in many short CPU bursts.
CPU-bound processes: Spend more time doing computations, with few very long CPU bursts.
What is one of the goals of the long-term scheduler in terms of process mix?
The long-term scheduler strives to achieve a good mix of I/O-bound and CPU-bound processes.
When is a medium-term scheduler used in an operating system?
It is used when the degree of multiprogramming needs to decrease; it swaps processes out of memory to disk and back in to manage active process counts.
What does the medium-term scheduler do during swapping?
It removes a process from memory (swap out) and later brings it back (swap in) so that execution can continue.
What is the function of the dispatcher in CPU scheduling?
The dispatcher transfers control of the CPU to the process selected by the scheduler, performing context switching, switching to user mode, and jumping to the proper location in the new program.
Why must the dispatcher be as fast as possible?
Because it is executed on every context switch; its time consumption (dispatch latency) directly affects overall system performance.
When does the short-term scheduler make CPU scheduling decisions?
- Switches from running to a waiting state.
- Switches from running to the ready state.
- Switches from waiting to the ready state.
- Terminates.
Which scheduling actions are considered non-pre-emptive?
Scheduling triggered by a process switching from running to waiting (case 1) and upon termination (case 4) are non-pre-emptive; a new process must be selected.
What does pre-emptive scheduling allow regarding CPU allocation?
It allows a process to be interrupted so that the CPU can be reallocated to another process, offering the choice to continue with the current process or switch.
What characterizes a non-pre-emptive (cooperative) scheduling system?
A process continues to run until it voluntarily blocks or terminates; scheduling occurs only when it switches to waiting or terminates.
What enables pre-emptive scheduling, and what is its main risk?
Pre-emptive scheduling is enabled by hardware that supports a timer interrupt. The main risk is that a process might be interrupted while updating shared data structures, potentially causing inconsistency.
What are some key criteria that CPU scheduling aims to optimize?
Criteria include maximizing CPU utilization, ensuring fairness among processes, minimizing waiting time, and maintaining efficiency under dynamic conditions.