What is an Operating System?
An Operating System (OS) is an interface over the computer hardware that lets users interact with the hardware with ease. The OS is a software that allows the user to do file management, device management, computation, etc, and also takes care of resource allocation, memory management, process management, etc.
Applications of an Operating System
The major applications of an operating system are:
- Process Management
- Memory Management
- Device Management
- File Management
- Others (Security, Coordination, Accounting, etc)
Let's try to understand more about the major applications.
Process Management
The OS decides which process gets processed when and for how much time through process scheduling. It also helps different processes coordinate when they are working with shared resources and data. It also takes care of handling deadlock scenarios where one process is waiting on the other process to release a resource and vice versa.
Memory Management
The OS tracks the status of each memory location and decides which process is allocated which memory locations, when, and for how long.
Device Management
The OS manages communication with devices through drivers. It tracks the status of each device and decides which process gets to communicate with the device, when, and for how long.
File Management
The OS allows users or programs to create, read, update or delete files and directories. It also keeps track of all the meta details about the files and directories through a file system.
Services provided by an Operating System
An Operating System provides different services to the users and the programs. The common services provided by an operating system are:
- Program Execution: The OS allows program execution by creating a process for every program that the user wants to execute including the applications that the user uses.
- Input/Output Operations: The OS handles the input-output operations through device drivers. The drivers help create an abstraction over actual system operations by allowing us to interact with the system using user-friendly devices.
- File System Management: The OS allows the users to create, read, update or delete files and directories. It also allows setting access controls on the files and directories.
- Communication: The OS allows communication between different processes through Inter-Process Communication (IPC).
- Error Detection and Handling: An error can happen in the hardware (CPU, RAM, I/O devices, etc) or any of the software. The OS detects and handles the error so that the user can use the system.
- Resource Allocation and Management: The OS manages all the resources like memory, CPU, storage, etc, and decides which resource is allocated which resource, when, and for how long.
- Accounting: The OS accounts and tracks all the activities including the errors happening on the computer.
- Security and Protection: The OS provides security and protection through different security and access control functionalities to save the data from getting stolen or corrupted by malware.
Kernel, Booting, and System Calls
The kernel is the core part of the operating system. It facilitates interactions between the hardware and the software and has complete control over everything.
On most systems, it is loaded at boot time (when the computer starts). The kernel is usually loaded after certain tests are done by the OS. After the kernel is loaded, it takes care of the rest of the booting.
A system call is an interface through which programs request services from the kernel. The services could be something like creating new processes, scheduling processes, interacting with hardware, etc.
Multiprogramming, Multitasking, and Multiprocessing
Multiprogramming is a technique through which a CPU can execute multiple jobs thereby increasing CPU utilization. This is generally done by keeping multiple jobs in the memory and then using some scheduling algorithm to decide which job is picked when.
Multitasking is an extension of multiprogramming in which more than one job is done at the same time. This is done by switching between tasks based on the user interaction or based on assigned time. The switching is very fast, so we do not see any lag when switching between different applications.
Multiprocessing is a technique in which there are two or more CPUs (processors) within the same computer. This allows us to run different processes on the same computer at the same time. There are certain components shared between the different processors like memory, clock, etc.
