Operating Systems · Contiguous Memory Allocation
CPU Utilization and Degree of Multiprogramming
Overview
CPU utilization measures how much of the time the CPU is actually running programs rather than sitting idle waiting for I/O. It depends directly on the degree of multiprogramming — the number of processes held in main memory — so memory management aims to keep as many processes in memory as possible.
Key concepts
- CPU utilization: the fraction of time the CPU is busy running programs. If a process spends fraction of its time waiting for or doing I/O, it uses the CPU for the remaining fraction.
- Degree of multiprogramming (): the number of processes that can be present in main memory at any one time.
- Direct relationship: CPU utilization rises with the number of processes in main memory, because when one process waits for I/O the CPU can run another.
- Idle condition: with processes, the CPU is idle only when all processes are doing I/O simultaneously; the probability of this is .
- Practical goal of memory management: with finite memory, use memory-management techniques to keep as many processes as possible in main memory, making finite memory behave as if it can hold many processes (mimicking infinite memory) to raise CPU utilization.
- New issues with multiple processes in memory: how much memory each process gets, how memory is allocated, how it is deallocated, and how protection among processes is provided.
The memory manager handles allocation, deallocation, and security/protection.
How it works
- A single process in memory uses the CPU for of the time and waits for I/O for of the time, so CPU utilization is .
- Adding main memory lets more processes reside in memory at once; the count is memory size divided by process size.
- With processes, the CPU is idle only when all wait for I/O at the same time, which happens with probability ; hence CPU utilization is .
- As grows, shrinks, so utilization rises — but each equal addition of memory yields a smaller gain.
- In the limit of infinitely many processes, utilization approaches 100%, but infinite memory is impractical because it is very costly.
Formulas
-
(one process in memory)
-
( processes in memory)
-
= fraction of time a process waits for/does I/O, with
-
= degree of multiprogramming = number of processes present in main memory at the same time
-
= probability/fraction of time all processes wait for I/O simultaneously, so the CPU is idle
-
= fraction of time at least one process is able to use the CPU
-
Limiting case: as , , so .
Worked examples
Assumptions: process size = 4 MB; operating-system overhead is ignored, so the stated main memory is fully available for user processes; .
| Main memory | Processes = memory / 4 MB | CPU utilization = | Approximate value | |
|---|---|---|---|---|
| 4 MB | 1 | 0.8 | 0.2 | 20% |
| 16 MB | 4 | 0.5904 | about 60% | |
| 32 MB | 8 | 0.8322 | about 83% | |
| 48 MB | 12 | 0.9313 | about 93% |
Step-by-step:
- 4 MB memory: ; utilization . The CPU is idle 80% of the time because the only process is usually waiting for I/O.
- 16 MB memory: ; probability all 4 wait for I/O ; utilization . Gain from the one-process case: about 20% to about 60%, roughly +40 percentage points.
- 32 MB memory: ; ; utilization . Gain from 16 MB to 32 MB: roughly +23 percentage points.
- 48 MB memory: ; ; utilization . Gain from 32 MB to 48 MB: roughly +10 percentage points.
- Limiting case: for , as , , so utilization .
Comparison
Gain in CPU utilization is not linear with memory size (same memory added each time, ):
| Memory step | Utilization change | Gain |
|---|---|---|
| 4 MB → 16 MB | about 20% → about 60% | about +40 percentage points |
| 16 MB → 32 MB | about 60% → about 83% | about +23 percentage points |
| 32 MB → 48 MB | about 83% → about 93% | about +10 percentage points |
Revision summary
- With one process, utilization is ; with processes, it is .
- is the fraction of time all processes wait for I/O simultaneously — then the CPU is idle.
- More memory means a higher degree of multiprogramming, which means higher CPU utilization.
- The improvement is not linear: equal memory additions give smaller and smaller gains.
- 100% utilization needs infinitely many processes in memory, which is impractical because infinite memory is very costly.
- The model assumes the OS is not counted in memory and that process size is fixed (4 MB in the examples).
- With multiple processes, the memory manager must also decide how much memory each process gets and provide protection among processes, not just allocation and deallocation.
Previous-year exam insights
- CPU utilization can also be computed from the arrival rate and service time: if processes arrive at rate λ (per unit time) and each needs an average service time S, then utilization U = λ × S as a fraction (multiply by 100 for %).
If λS ≥ 1 the single CPU is saturated and utilization is taken as 100%; make the units of λ and S consistent (e.g., convert processes per minute to processes per second).
Asked inUGC NET 2014ISRO 2011 - To find how many processes must be resident to reach a target utilization U, solve (take the ceiling); the required n grows rapidly as U approaches 1 because gains diminish.
- The degree of multiprogramming is the number of processes resident in main memory, not the total number of processes in the system (processes swapped out or waiting on disk do not count).
If the OS occupies part of memory, n = floor((main memory − OS resident size)/process size);
for processes of unequal size, memory is packed until no further process fits. - The relation utilization = assumes that the n processes' I/O waits are independent (so the probability all are waiting is exactly ) and that memory is the only constraint.
If the I/O waits are correlated or synchronized the actual utilization is lower than , and as p → 1 the utilization tends to 0 for any finite n. - The monotonic rise of CPU utilization with n holds only while the system is not thrashing: with demand paging/virtual memory, increasing the degree of multiprogramming beyond a point raises the page-fault rate, so utilization drops instead of approaching 1 — is an idealised model ignoring paging overhead.
- CPU utilization and CPU idle time are complements: with n processes, idle time fraction = (all waiting for I/O) and busy time fraction = ;
for one process these reduce to p and 1 - p, and neither nor is the utilization of an n-process system.
Asked inUGC NET 2008