Interrupts
An interrupt is a signal that temporarily stops the CPU from its current task. The CPU to pause the current program. It then runs a program called an Interrupt Service Routine. After the interrupt, the CPU resumes the original program.
Interrupt Priorities
Multiple interrupts may occur at the same time. Higher-priority interrupts are handled first. Lower-priority interrupts may be delayed. A higher-priority interrupt can interrupt a lower-priority ISR.
Multi-programming
Multiprogramming handles CPU efficiency at a low level: The OS keeps multiple programs in memory. When one program waits for I/O, the CPU can immediately switch to another program.
This ensures the CPU is almost never idle.
Multi-tasking
Multitasking handles user experience at a high level: The OS divides CPU time among many processes quickly. Each program seems to run simultaneously to the user, even if the CPU can really run only one instruction at a time.
Partitioning
Partitioning is when main memory is divided into sections so that multiple processes can be stored and run at the same time.
Purpose of Partitioning
Processes must be allocated an exclusive area of main memory. An allocated area of memory cannot be used by a second process until the first process is complete and de-allocated from memory.
Fixed Partitioning
Main memory is divided into a set number of non over-lapping sizes that are fixed. Sizes are decided in advance, and a process may be loaded into a partition of equal or greater size and is confined to its allocated partition.
Variable Partitioning
Variable partitioning is a system for dividing memory into non-overlapping but variable sizes. The number of partitions is fixed but the size of each partition may vary. More flexible than the fixed partitioning configuration, where small processes are allocated to small partitions and large processes allocated to larger partitions.
Dynamic Partitioning
Partitions are not made before execution but during run-time according to processes’ needs, with the size of partition equal to the size of incoming process. The number of partitions is not fixed but depends on the number of incoming processes and size of main memory.
Pros: No Internal fragmentation. No restriction on degree of multiprogramming. No restriction of process size.
Cons: More difficult to implement as it requires allocation of memory during run-time. External fragmentation may still arise.
Internal Fragmentation
Small processes with respect to the fixed partition sizes results in occupied partitions with lots of unoccupied space left.
External Fragmentation
Free memory exists but is split into small gaps and no single block is large enough for a new process.
Performance overhead
More time spent managing memory instead of executing programs.
Limitation on degree of Multiprogramming
Partitions in main memory are made before execution. The number of processes cannot be greater than the number of partitions in memory.
Paging
Paging divides memory and programs into
fixed-size blocks. Pages can be stored in any frame. Eliminates external fragmentation.
How Paging works
Program is split into pages. RAM is split into frames. Page Table keeps track of where each page is stored. CPU generates a logical address MMU converts it to a physical address.
Advantages of Paging
Disadvantages of Paging
Segmentation
Segmentation is a memory management technique where a program is divided into logical segments. This means we can use segments of exact size requested rather than forcing data into fixed sized chunks.
How Segmentation works
Program is divided into logical segments. Each segment has a variable size, unlike fixed-size pages. RAM stores segments in contiguous memory locations. A Segment Table keeps track of each segment’s base address and limit. CPU generates a logical address. MMU checks the offset against the segment limit and converts it to a physical address.
Advantages of Segmentation
It supports logical program structure, making programs easier to manage and protect. Different segments can have different access permissions. It allows sharing of segments like libraries between processes.
Disadvantages of Segmentation
It suffers from external fragmentation because segments are variable in size. Memory allocation and compaction become more complex. It is generally slower than paging due to the need for dynamic memory management.
Data Transfer
Data transfer is the movement of data between:
CPU and Memory.
Memory and Input/Output devices.
Buffers
A buffer is a temporary storage area in memory used during data transfer. Example: Printer. CPU sends data quickly to a buffer. CPU continues other tasks.Printer reads data slowly from the buffer. Prevents CPU from being blocked and
smooths out speed differences.
Memory Buffering
The temporary storage in memory of information / processes that are waiting to be executed.