Functions of an Operating System
As discussed in the previous chapter, an operating system (OS) is the backbone of any computing device, acting as an intermediary between hardware and software.
It manages resources, ensures system stability, and provides a user-friendly interface. Let's explore the core functions of an operating system in detail.Note
This section builds on the previous discussion of the role of operating systems by focusing on specific functions and how they manage system resources.
Maintaining System Integrity
- System integrity refers to the ability of a computer system to perform its intended functions correctly and reliably, without unauthorized or unintended alterations.
- The OS ensures this through several mechanisms:
- Process Isolation: Each process operates in its own virtual memory space, preventing interference with other processes or the OS itself.
- Memory Protection: The OS enforces boundaries between processes, ensuring that one process cannot access the memory of another.
- User Mode and Kernel Mode: These modes separate operations that require direct hardware access (kernel mode) from those that do not (user mode).
- Think of an operating system as a security guard in a building.
- Just as a guard ensures that only authorized personnel access certain areas, the OS enforces rules to keep processes and data safe from unauthorized access or interference.
Memory Management
Memory management is a critical function of the OS, ensuring efficient use of both physical and virtual memory.
- Allocation and Deallocation: The OS assigns memory to processes as needed and reclaims it when no longer in use.
- Virtual Memory: This allows processes to use more memory than physically available by swapping data between RAM and disk storage.
- Paging and Segmentation: These techniques divide memory into manageable units, enabling efficient allocation and protection.
Virtual memory creates the illusion of a large, continuous memory space, even if physical RAM is limited.
File System Management
The OS manages data storage through file systems, which organize and control access to files and directories.
- File Creation and Deletion: The OS handles the creation, modification, and deletion of files.
- Permissions and Security: It enforces access controls to ensure only authorized users can read, write, or execute files.
- Disk Space Allocation: The OS optimizes the use of storage space and maintains file system integrity.
- Abstraction: The OS provides an interface of directories, sub-directories and files for the user to access rather than the user having to memorize exact addresses of files and applications.
- When designing a file system, consider both performance and security.
- Efficient indexing and robust permission structures are key to a well-functioning system.
Device Management
Device management enables communication between the OS and hardware components.
- Device Drivers: These software modules translate OS commands into signals that specific hardware devices can understand.
- Interrupt Handling: The OS responds to signals from devices, such as keyboard input or network data, ensuring timely processing.
- Error Handling: The OS manages hardware errors and provides a consistent interface for applications to access devices.
Drivers are essential in compatibility of peripherals with computer manufactures.
- Computer manufactures cannot account for every possible different peripheral manufacturers devices.
- Even within well known companies there are hundreds of devices with different models that would have to be accounted for and specially programmed in if there were no drivers.
- If new peripherals were designed after the computer then how would the computer know how to communicate with them.
Device management is distinct from I/O management, which focuses on data flow between the CPU and peripherals.
Scheduling
Scheduling determines the order and timing of process execution, balancing system performance and responsiveness.
- CPU Scheduling: The OS allocates CPU time to processes based on priority, fairness, and efficiency.
- Pre-emption: High-priority processes can interrupt lower-priority ones to ensure critical tasks are completed promptly.
- Algorithms: Common scheduling algorithms include round robin, priority scheduling, and multilevel queue scheduling.