OS 2.01 - OS Services
The main three aspects of an OS are its Services, Interfaces, and Components.
OS Components and Their Interconnection
The OS is made up of several interconnected components that work together to provide the services required by both users and applications. These components include:
Kernel: The core part of the OS responsible for managing hardware resources and facilitating communication between hardware and software. The kernel interacts directly with the hardware, scheduling processes and managing memory.
Process Management: This component manages the creation, scheduling, and termination of processes. It also handles inter-process communication and synchronization.
Memory Management: The memory manager allocates and deallocates memory for processes and ensures efficient use of available memory, including virtual memory management.
File System: This component handles the organization, storage, retrieval, and manipulation of data in files. It also manages file access permissions.
I/O System: The I/O system facilitates communication between the OS and external devices, such as hard drives, printers, and displays.
Security and Protection: The OS uses this component to enforce security policies and ensure that resources are protected from unauthorized access.

Operating System Services
An operating system provides various services that enable the proper functioning of applications, hardware, and system management.
These services are crucial for handling processes, input/output (I/O), memory management, and security.
1. Program Execution
The OS is responsible for loading a program into memory, executing it, and managing its life-cycle.
This includes terminating the program either normally or abnormally (e.g., due to an error or user request).
2. I/O Operations
I/O operations involve interacting with devices like storage drives, printers, or networks. e.g., reading data from a keyboard, writing data to a screen.
The OS acts as an intermediary to ensure that programs can perform I/O operations efficiently and securely.
3. File-System Manipulation
The OS allows programs to create, read, write, and delete files or directories.
It manages the storage and retrieval of data on disk and ensures file system integrity. Many operating systems also provide permissions management, which controls access to files and directories based on user roles and ownership.
4. Communication Between Processes
Operating systems provide mechanisms for communication between processes, both local and remote. This communication can be achieved via:
- Shared Memory: Multiple processes access and modify the same region of memory.
- Message Passing: Processes exchange data in pre-defined formats, typically over a network.
5. Error Detection
The OS continuously monitors the system for errors, such as hardware malfunctions or application issues and take corrective action, such as terminating a malfunctioning process or halting the entire system if necessary.
Another set of operating system functions exists not for helping the user but rather for ensuring the efficient operation of the system itself.
6. Resource Allocation
When multiple users or processes are running simultaneously, the OS allocates resources such as CPU time, memory, and I/O devices.
For example, the OS uses scheduling algorithms to manage CPU cycles and prioritize processes. It also manages the allocation and release of peripheral devices like printers or network interfaces.
7. Accounting
The OS keeps track of resource usage by users and processes.
This can be used for billing purposes in multi-user environments or for analyzing system performance to optimize resource allocation.
8. Protection and Security
- Protection involves ensuring that processes cannot interfere with one another or the OS itself. This is achieved through memory protection, process isolation, and access control mechanisms.
- Security is about protecting the system from external unauthorized access, by requiring user authentication (e.g., passwords) and monitoring external device access, recording all such connections for detection of break-in. The OS defends against external threats like malware and intrusions.
User Interface (UI)
The user interface of an OS allows interaction between the user and the system.
Common types of user interfaces include:
1. Command-Line Interface (CLI)
- Users interact with the OS by typing text-based commands. The CLI offers fine-grained control over system operations but requires users to have knowledge of specific commands. Example: Linux Shell, Windows Command Prompt.
2. Batch Interface
- In a batch interface, commands and scripts are written into files, which are then executed by the OS without real-time user interaction. Example: Batch processing scripts in mainframe systems.
3. Graphical User Interface (GUI)
- A GUI uses windows, icons, menus, and pointers (WIMP) to provide a more user-friendly interface. Users interact with the system using pointing devices like a mouse or touchpad. Example: Microsoft Windows, macOS, Linux Desktop environments like GNOME or KDE.
4. Hybrid Interfaces
- Some OS provide combinations of these interfaces, allowing users to switch between CLI and GUI depending on their needs.
System Calls
System calls provide a way for programs to request services from the operating system. These calls act as the interface between a user program and the OS kernel.
Common system calls include:
- Process control: Creating, scheduling, or terminating processes.
- File management: Opening, reading, writing, or closing files.
- Device management: Interacting with I/O devices (e.g., printers, disk drives).
- Memory management: Allocating and deallocating memory for processes.