Operating System Introduction
Operating System Introduction
An Operating System (OS) is system software that manages computer hardware and software
resources, providing common services for computer programs. It serves as an intermediary
between users and the hardware, allowing applications to run without having to deal directly
with hardware components.
Examples of operating systems
1. Microsoft Windows: Widely used for personal and business desktops, featuring a user-
friendly GUI. Versions include Windows 10, Windows 11.
2. Linux: Open-source, used in servers, desktops, and embedded systems. Known for
flexibility and security. Popular distributions include Ubuntu, Fedora.
3. macOS: Developed by Apple for its computers, known for performance and integration
with Apple devices. Versions include macOS Monterey, Ventura.
4. Android: Open-source mobile OS by Google, used on smartphones and tablets. Versions
include Android 12, Android 13.
5. iOS: Proprietary mobile OS by Apple, used on iPhones and iPads. Known for security
and performance. Versions include iOS 16, iOS 17.
6. Chrome OS: Lightweight, cloud-based OS by Google, used on Chromebooks for
browsing and web apps.
7. Unix: Powerful, multi-user OS, commonly used in servers and enterprise systems.
Operating System services
1. Process Management
The OS handles the creation, scheduling, and termination of processes. It ensures efficient CPU
usage by managing multiple processes, allowing multitasking. Through process scheduling and
context switching, the OS decides which process gets CPU time and when. It also tracks process
states, including running, ready, and waiting.
2. Memory Management
The OS manages the computer's memory by allocating and deallocating memory to processes. It
ensures that each process has enough memory and prevents processes from interfering with each
other. Using virtual memory, the OS can extend available memory by swapping data to and from
the hard disk. It also protects memory to ensure system stability.
1
3. File System Management
The OS manages the organization, storage, and retrieval of files on storage devices. It provides a
way for users and applications to access files, handle file creation, deletion, and modification.
The OS organizes files into directories and enforces access control policies, ensuring secure and
efficient file management.
4. Device Management
The OS controls hardware devices through device drivers, facilitating communication between
software and hardware. It handles input/output (I/O) operations, manages device scheduling, and
prioritizes tasks for devices like printers, keyboards, and displays. It ensures that multiple
processes can share devices without conflict.
5. Security and Access Control
The OS enforces security measures to protect data and system resources. It includes user
authentication, such as passwords, and controls access to files and devices. The OS uses
encryption and other techniques to protect sensitive data and ensure that only authorized users
and processes can access restricted resources.
6. Networking
The OS facilitates communication between computers over networks. It manages network
connections and data transmission using networking protocols like TCP/IP. The OS handles tasks
such as IP addressing, routing, and securing data exchanges, allowing devices to connect and
share resources over local and wide-area networks.
7. User Interface
The OS provides various interfaces for users to interact with the system. This includes a
Graphical User Interface (GUI), which uses icons, windows, and visual elements to make
interaction more intuitive and user-friendly. On the other hand, the Command-Line Interface
(CLI) offers more control, relying on text-based commands for direct system interaction.
Additionally, the OS supports a Batch Interface, where users can execute a series of commands
or scripts automatically without needing real-time input. Batch processing is particularly useful
for repetitive tasks and system maintenance. The OS also includes accessibility features to
support users with disabilities, ensuring that everyone can effectively interact with the system.
8. System Performance and Monitoring
2
The OS monitors system performance, ensuring efficient resource allocation. It tracks CPU
usage, memory, disk activity, and network traffic, identifying potential bottlenecks. System
monitoring tools provide insights into performance issues, helping users and administrators
maintain optimal system operation. The OS also balances loads across resources to enhance
performance.
Process Definition
A process is an instance of a program in execution. It is a dynamic entity that consists of the
program code (the text section), its current activity, a stack (containing temporary data like
function parameters, return addresses), and a heap (for dynamically allocated memory). A
process also includes information such as the program counter, CPU registers, and I/O status.
Processes are fundamental to the functioning of modern operating systems, as they are the active
entities that utilize the system's resources.
Each process is assigned a unique Process Control Block (PCB), which holds information about
the process, including its state, program counter, CPU registers, memory management details,
and accounting information. The OS manages the execution and transitions of processes between
various states based on events and scheduling.
Process States
1. New
3
The process is being created. In this state, the OS is allocating resources like
memory and process control blocks (PCB). The process has not yet started
execution.
2. Ready
The process is loaded into memory and ready to execute, but it is waiting for CPU
time. The process is in the ready queue, and the OS scheduler will pick it to
execute when the CPU is available.
3. Running
The process is currently being executed by the CPU. At this point, the process is
performing its tasks and utilizing system resources.
4. Waiting (Blocked)
The process cannot proceed because it is waiting for some external event or
resource, such as I/O completion or a resource becoming available. It is
temporarily halted until the event occurs.
5. Suspended Ready
The process is not executing but is in memory and ready to run. It has been
moved from the Ready state to suspended due to resource constraints (e.g.,
limited memory).
6. Suspended Waiting
The process is waiting for an external event (like I/O) but has been moved out of
memory to save resources. It is not currently executing, but it is still in the waiting
state.
7. Terminated
The process has completed its execution or was forcibly terminated. At this point,
the OS will clean up and release resources allocated to the process, such as
memory and file handles.
Process Transitions
1. New → Ready
A process moves from the new state to the ready state once it is fully initialized
and is waiting for CPU time.
2. Ready → Running
4
The process moves from the ready state to the running state when the scheduler
assigns CPU time to it.
3. Running → Waiting (Blocked)
A process moves from running to waiting if it needs to wait for some external
event, such as I/O completion or resource availability.
4. Running → Ready
A process moves from running to ready if it is preempted (e.g., due to time slice
expiration or higher-priority processes), or if the scheduler decides to pause it.
5. Waiting → Ready
A process moves from the waiting state back to the ready state once the event or
resource it was waiting for becomes available.
6. Ready → Suspended Ready
If the system has limited resources (like memory), a process in the ready state
may be suspended to free up space, moving to the suspended ready state.
7. Waiting → Suspended Waiting
A waiting process can be swapped out of memory to save resources, moving it to
the suspended waiting state.
8. Suspended Ready → Ready
When the system has more available resources, a process in the suspended ready
state is moved back to the ready state.
9. Suspended Waiting → Waiting
When the process in the suspended waiting state is loaded back into memory, it
resumes waiting for the event or resource to become available.
10. Running → Terminated
Once a process completes its execution or is forcibly terminated (e.g., due to an error), it
moves to the terminated state. The OS then releases the resources allocated to the
process.
11. Waiting → Terminated
If a process in the waiting state has been stuck waiting for too long, it can be forcefully
terminated by the OS, moving it directly to the terminated state.
5
These transitions are controlled by the operating system scheduler, which determines when a
process moves from one state to another based on factors like time-slicing, resource availability,
and process priority.
Multiprogramming
Multiprogramming is a technique where multiple programs are loaded into memory, and the
CPU switches between them to maximize CPU utilization. It ensures that the CPU is always
active by executing one program while others wait for I/O operations.
Example: On older mainframe systems, while one program waits for data from a disk (I/O), the
CPU would switch to another program, allowing efficient use of processing time.
Multitasking
Multitasking allows the operating system to run multiple tasks or processes seemingly
simultaneously by rapidly switching between them. It can give the illusion of simultaneous
execution and is commonly used in modern operating systems. In systems with multiple CPU
cores, true parallelism is achieved, where tasks are run on different cores simultaneously.
Example: In a modern desktop operating system like Windows, a user can have a web browser
open, listen to music, and edit a document at the same time. The OS switches between these
tasks quickly, and in systems with multi-core processors, each task can run on a different core for
true parallel execution.
Multiprocessing
Multiprocessing uses multiple processors or CPU cores to execute tasks in true parallelism,
enhancing performance and efficiency. Unlike multitasking or multiprogramming, it allows
simultaneous execution of processes by dividing them among processors.
Example: Rendering different sections of a video simultaneously on multiple processors to
reduce rendering time.