OPERATING SYSTEM
OPERATING SYSTEM OVERVIEW:
1. INTRODUCTION
2. OPERATING SYSTEM FUNCTIONS
An Operating System acts as a communication interface between the user
and computer hardware. Its purpose is to provide a platform on which a user
can execute programs conveniently and efficiently. The main goal of an
operating system is to make the computer environment more convenient to
use and to utilize resources most efficiently.
Operating System handles the following responsibilities:
Controls all the computer resources.
Provides valuable services to user programs.
Coordinates the execution of user programs.
Provides resources for user programs.
Provides an interface (virtual machine) to the user.
Hides the complexity of software.
Supports multiple execution modes.
Monitors the execution of user programs to prevent errors.
Functions of an Operating System
Function of OS
1. Process Management
Process management in operating system is about managing processes.
A Process is a running program. The life cycle of process is from the moment
program start until it finishes. Operating system makes sure each process:
gets its turn to use the CPU
synchronized when needed
has access to the resources it needs, like memory, files, and input/output
devices.
It also handles issues like process coordination and communication, while
preventing conflicts such as deadlocks. This way, the OS ensures smooth
multitasking and efficient resource use.
Process State Diagram
Core Functions in Process Management:
Process Scheduling
Allocates CPU time to processes based on scheduling algorithms
like Round Robin or Priority Scheduling.
Ensures fair distribution of CPU time, avoiding starvation of lower-priority
processes.
Maximizes CPU utilization by determining which process runs at any given
time.
Process Synchronization
Coordinate multiple processes to ensure orderly execution and prevent
conflicts.
Prevents race conditions by ensuring that only one process can access a
shared resource at a time.
Uses synchronization mechanisms like locks, semaphores, and monitors to
coordinate process access.
Deadlock Handling
Prevents deadlocks by using strategies like resource allocation graphs or
avoiding circular wait conditions.
Detects deadlocks when they occur, allowing the system to identify and
resolve the issue.
Recovers from deadlocks by aborting or rolling back processes to free up
resources.
Inter-Process Communication (IPC):
Facilitates communication between processes through shared memory,
allowing processes to exchange data directly.
Uses message passing to send data between processes in different
address spaces.
Enables efficient data exchange and coordination in a multitasking
environment, improving system performance.
Read more about Process Management in OS
2. Memory Management
Memory management is an essential task of the operating system that
handles the storage and organization of data in both main (primary)
memory and secondary storage. The OS ensures that memory is allocated
and deallocated properly to keep programs running smoothly. It also manages
the interaction between volatile main memory and non-volatile secondary
storage.
Memory Management
Key Activities in Memory Management:
Main Memory Management
Memory Allocation: Assigns memory to processes using techniques
like paging and segmentation.
Memory Deallocation: Frees memory when no longer needed.
Memory Protection: Prevents processes from accessing each other’s
memory.
Virtual Memory: Uses disk space as extra memory to run larger
processes.
Fragmentation: Manages wasted memory space (internal/external)
through compaction.
Secondary Memory Management
Disk Space Allocation: Organizes how files are stored on the disk
(contiguous, linked, indexed).
File System Management: Manages files and directories for efficient data
access.
Free Space Management: Tracks available space on the disk.
Disk Scheduling: Organizes the order of disk read/write requests.
Backup and Recovery: Ensures data is backed up and can be restored
after failure.
3. File System Management
File management in the operating system ensures the organized storage,
access and control of files. The OS abstracts the physical storage details to
present a logical view of files, making it easier for users to work with data. It
manages how files are stored on different types of storage devices (like hard
drives or SSDs) and ensures smooth access through directories and
permissions.
File System Management includes managing of:
File Attributes
File Name: Identifies the file with a name and extension (e.g., .txt, .jpg).
File Type: Defines the format of the file (e.g., text, image, executable).
Size: The amount of storage the file occupies.
Permissions: Determines who can read, write, or execute the file.
File Types
Text Files: Contain human-readable content (e.g., .txt, .md).
Binary Files: Store data in binary format (e.g., .jpg, .mp3).
Executable Files: Contain program code (e.g., .exe, .out).
Operations on Files
Create: Allows users to create new files.
Read: Opens files to read their contents.
Write: Modifies the contents of a file.
Delete: Removes a file from the system.
Access Methods
Sequential Access: Reads data in order, from start to finish.
Direct Access: Jumps to a specific part of the file.
Indexed Access: Uses an index for quick data retrieval.
4. Device Management (I/O System)
Device management of an operating system handles the communication
between the system and its hardware devices, like printers, disks or network
interfaces. The OS provides device drivers to control these devices, using
techniques like Direct Memory Access (DMA) for efficient data transfer and
strategies like buffering and spooling to ensure smooth operation.
Device Management
Major components in Device Management:
Device Drivers: The operating system uses device drivers to interact with
hardware devices.
There are two types of device drivers:
Kernel-space drivers run in the OS kernel, offering direct access to
hardware.
User-space drivers run outside the kernel and are more isolated,
providing safety but less performance.
Buffering & Caching:
Buffering temporarily stores data in memory to manage differences in
device speeds. Block devices (e.g., hard drives) use larger blocks of data
for buffering, while character devices (e.g., keyboards, mice) use smaller,
byte-by-byte buffering.
Caching improves access speed by storing frequently accessed data in a
faster storage medium (like RAM).
Spooling: Spooling manages data waiting to be processed, particularly in
devices like printers. The OS places print jobs in a spool (a temporary storage
area), allowing the CPU to continue other tasks while the printer works
through the queue. Other examples include mail spooling (for managing
outgoing email) and batch-job spooling (for managing scheduled tasks).
5. Protection and Security
Protection and security mechanisms in an operating system are designed to
safeguard system resources from unauthorized access or misuse. These
mechanisms control which processes or users can access specific resources
(such as memory, files, and CPU time) and ensure that only authorized users
can perform specific actions. While protection ensures proper access control,
security focuses on defending the system against external and internal
attacks.
Access Control: The operating system ensures that processes and users
can only access resources they are authorized to. This is achieved through
mechanisms like memory-addressing hardware (which keeps processes
within their own address space) and timer interrupts (which prevent
processes from monopolizing the CPU).
User Authentication: A system identifies users through user IDs (UIDs) or
Security IDs (SIDs). During login, the operating system verifies the user’s
credentials, ensuring that only authorized users can access their data or
system resources.
Resource Protection: Mechanisms like file protection (ensuring only
authorized users can access or modify files) and device protection
(restricting direct access to device-control registers) ensure the integrity of
system resources, preventing unauthorized or harmful use.
Security Against Attacks: Security mechanisms defend against external
threats like viruses, worms, denial-of-service attacks, and identity theft.
These attacks can misuse system resources, steal sensitive data, or
disrupt system operation. The OS works to prevent these threats and
minimize damage.