OPERATING SYSTEM BASICS
Site: | Fiona Kerubo Omoi elearning platform |
Course: | Fiona Kerubo Omoi elearning platform |
Book: | OPERATING SYSTEM BASICS |
Printed by: | |
Date: | Thursday, 16 October 2025, 12:22 PM |
Description
This book covers the core topics in operating system including process management ,memory and file systems.
1. INTRODUCTION TO OPERATING SYSTEM
An Operating System (OS) is a fundamental software that acts as an interface between the user and the computer hardware. It manages all hardware and software resources, enabling users and applications to interact with the computer system efficiently.
Definition
An Operating System is system software that manages computer hardware, software resources, and provides common services for computer programs.
Functions of an Operating System
The primary functions of an operating system include:
-
Process Management
It handles the creation, scheduling, and termination of processes. The OS ensures smooth execution by managing process states and priorities. -
Memory Management
It manages the allocation and deallocation of memory space to different programs and users to ensure efficient memory use. -
File System Management
The OS controls the reading, writing, creation, and deletion of files and directories. It also manages file permissions and storage. -
Device Management
It manages hardware devices through drivers, ensuring smooth communication between hardware and software. -
Security and Access Control
The OS protects data and system resources through user authentication, permissions, and encryption. -
User Interface
Provides a user-friendly interface—either Command Line Interface (CLI) or Graphical User Interface (GUI)—for interacting with the system.
Types of Operating Systems
-
Batch Operating System
Executes batches of jobs with minimal user interaction. -
Time-Sharing Operating System
Allows multiple users to use the system simultaneously by sharing time slots. -
Distributed Operating System
Manages a group of independent computers and makes them appear as a single system. -
Real-Time Operating System (RTOS)
Used in systems that require immediate processing and response, such as medical systems or embedded devices. -
Network Operating System
Supports networking functions like file sharing and communication between computers. -
Mobile Operating System
Specialized OS designed for mobile devices, e.g., Android and iOS.
Examples of Operating Systems
-
Microsoft Windows
-
macOS
-
Linux
-
UNIX
-
Android
-
iOS
1.1. WHAT IS AN OPERATING SYSTEM
1.0.1 Introduction
An Operating System (OS) is system software that manages all hardware and software resources of a computer system. It provides a user-friendly environment so users can interact with the machine effectively, and it enables application software to function by managing the system's underlying operations.
In simpler terms, the operating system is the software that makes the computer work. Without it, users cannot run applications, interact with files, or use hardware devices.
1.0.2 Definition
An Operating System is defined as:
"A system software that acts as an interface between the user and the hardware, and manages system resources such as CPU, memory, input/output devices, and storage."
1.0.3 Role of the Operating System
The OS acts as a middleman between:
-
The user and the hardware
-
The application software and the computer system
For example, when a user opens a web browser, it is the OS that loads it into memory, allocates CPU time to it, and handles inputs from the keyboard and mouse.
1.0.4 Objectives of an Operating System
The main goals of an operating system include:
-
Convenience: Makes using a computer easier.
-
Efficiency: Maximizes the use of computer resources.
-
Resource Management: Controls how hardware and software resources are used.
-
Security and Protection: Prevents unauthorized access and safeguards data.
1.0.5 Components of an Operating System
The OS is made up of several important components:
-
Kernel
-
The core part of the OS; manages memory, processes, and hardware.
-
-
Shell
-
The user interface, either command-line or graphical.
-
-
File System
-
Organizes and stores files on storage devices.
-
-
Device Drivers
-
Software that controls specific hardware components.
-
1.0.6 Real-World Examples of Operating Systems
-
Personal Computers: Windows, macOS, Linux
-
Servers: Ubuntu Server, Red Hat Enterprise Linux, Windows Server
-
Mobile Devices: Android, iOS
-
Embedded Systems: FreeRTOS, VxWorks
1.0.7 Importance of Operating System
Without an operating system:
-
Computers would be extremely hard to use.
-
Every software application would need to know how to interact with every piece of hardware.
-
Security, multitasking, and user management would be difficult to implement.
1.2. HISTORY AND TYPES OF OPERATING SYSTEM
2.1 History of Operating Systems
The development of operating systems has evolved alongside the advancement of computer hardware and user needs. The history can be divided into distinct generations or phases:
1st Generation (1940s – Early 1950s): No Operating System
-
Early computers like ENIAC had no operating systems.
-
Programs were input using punched cards and switches.
-
Each program controlled all hardware resources directly.
-
Computers could run only one task at a time.
2nd Generation (Mid 1950s – Early 1960s): Batch Operating Systems
-
Introduction of Batch Processing.
-
Jobs were grouped and processed one after another without user interaction.
-
Operating systems began to automate job scheduling and file management.
-
Example: IBM 7094 using FMS (Fortran Monitor System).
3rd Generation (Mid 1960s – 1970s): Multiprogramming and Time-Sharing OS
-
Introduction of multiprogramming: running multiple programs at once.
-
Time-sharing allowed multiple users to access the computer interactively.
-
UNIX was developed during this period.
-
Development of the kernel and improved resource management.
4th Generation (1980s – 1990s): GUI-Based Operating Systems
-
Rise of personal computers and user-friendly Graphical User Interfaces (GUI).
-
Popular OS like MS-DOS, Windows, and Mac OS emerged.
-
Operating systems became more interactive and visual.
5th Generation (2000s – Present): Modern and Mobile Operating Systems
-
Focus on connectivity, mobility, and security.
-
Rise of mobile OS (Android, iOS).
-
Introduction of cloud-based and distributed OS.
-
Real-Time OS used in embedded systems and IoT devices.
2.2 Types of Operating Systems
Operating systems are categorized based on their design, function, and usage:
1. Batch Operating System
-
Executes batches of jobs automatically without user interaction during processing.
-
Suitable for repetitive tasks with little need for real-time input/output.
-
Example: IBM Mainframe Systems.
2. Time-Sharing Operating System
-
Allows multiple users to share system resources simultaneously.
-
Each user gets a time slice of the CPU.
-
Example: UNIX.
3. Distributed Operating System
-
Connects multiple computers to work as a single system.
-
Resources are distributed but managed centrally.
-
Example: Amoeba, Mach.
4. Real-Time Operating System (RTOS)
-
Designed for time-critical applications.
-
Responses to inputs are immediate and predictable.
-
Used in embedded systems like automotive controllers and medical devices.
-
Examples: VxWorks, FreeRTOS.
5. Network Operating System (NOS)
-
Supports computers on a network by providing file sharing, communication, and centralized control.
-
Examples: Windows Server, Novell NetWare.
6. Mobile Operating System
-
Designed for mobile devices with touchscreens, sensors, and wireless communication.
-
Examples: Android, iOS.
7. Multi-user and Single-user OS
-
Multi-user OS allows multiple users to operate at once (e.g., Linux).
-
Single-user OS supports only one user at a time (e.g., Windows 10 Home).
8. Multitasking and Single-tasking OS
-
Multitasking OS runs multiple processes at once.
-
Single-tasking OS runs one program at a time (e.g., MS-DOS).
2. PROCESS MANAGEMENT
Process management is a core function of the operating system. It involves creating, scheduling, and terminating processes, as well as managing their execution and communication.
2.1. PROCESS LIFECYCLE
2.1.1 What is a Process?
A process is a program in execution. It is an active entity, unlike a program, which is a passive set of instructions stored on disk. A process requires resources such as CPU time, memory, files, and I/O devices to perform its task.
2.1.2 States of a Process
A process goes through several states during its execution. The major process states are:
-
New:
The process is being created. -
Ready:
The process is waiting in the queue to be assigned to the CPU. -
Running:
The process is currently being executed by the CPU. -
Waiting (Blocked):
The process is waiting for some event (like input from a device) to occur. -
Terminated:
The process has finished execution and is being removed from memory.
2.1.3 Process Control Block (PCB)
Each process has a Process Control Block (PCB) which stores important information such as:
-
Process ID
-
Process state
-
Program counter
-
CPU registers
-
Memory management information
-
I/O status
-
Accounting information
The OS uses the PCB to manage and track processes.
2.2. CPU SCHEDULING
2.2.1 What is CPU Scheduling?
CPU scheduling is the process by which the operating system selects one of the ready processes to be executed by the CPU. It is essential in a multiprogramming environment where multiple processes compete for CPU time.
2.2.2 Types of Schedulers
-
Long-Term Scheduler (Job Scheduler):
Decides which jobs or processes are admitted into the system for processing. -
Short-Term Scheduler (CPU Scheduler):
Selects from among the ready processes and allocates the CPU. -
Medium-Term Scheduler (optional):
Suspends and resumes processes to balance system load.
2.2.3 Scheduling Criteria
Effective scheduling aims to optimize the following:
-
CPU Utilization: Keep the CPU as busy as possible.
-
Throughput: Number of processes completed per unit time.
-
Turnaround Time: Total time taken from submission to completion.
-
Waiting Time: Time a process spends in the ready queue.
-
Response Time: Time from request submission to first response (important for interactive systems).
-
Fairness: All processes should get a fair share of CPU time.
2.2.4 CPU Scheduling Algorithms
-
First-Come, First-Served (FCFS)
-
Processes are scheduled in the order they arrive.
-
Simple but can lead to long waiting times.
-
-
Shortest Job Next (SJN) / Shortest Job First (SJF)
-
Process with the shortest execution time is scheduled first.
-
Optimizes average waiting time but may cause starvation.
-
-
Priority Scheduling
-
Each process is assigned a priority, and the highest priority process runs first.
-
Lower priority processes may starve.
-
-
Round Robin (RR)
-
Each process gets a fixed time slice (quantum) in a rotating order.
-
Good for time-sharing systems.
-
-
Multilevel Queue Scheduling
-
Processes are divided into multiple queues (e.g., foreground and background) with different scheduling policies.
-
2.2.5 Context Switching
When the CPU switches from one process to another, it performs a context switch, saving the state of the old process and loading the state of the new one. This introduces overhead, so efficient scheduling minimizes unnecessary context switches.
3. MEMORY MANAGEMENT
Memory Management is one of the most essential functions of an operating system (OS). It refers to the process of managing the computer's primary memory (main memory or RAM). The operating system is responsible for allocating memory to various programs and processes and reclaiming it when it's no longer needed. Efficient memory management ensures that the system runs smoothly and that multiple programs can run simultaneously without interfering with each other.
3.1. MEMORY ALLOCATION TECHNIQUES
There are two main types of memory allocation: static and dynamic. The OS uses various techniques to allocate memory effectively to ensure optimal performance and to prevent problems such as fragmentation and memory leaks.
3.1.1 Contiguous Memory Allocation
In this method, each process is allocated a single contiguous block of memory. This is simple and fast but can lead to fragmentation.
-
Fixed Partitioning: The memory is divided into fixed-sized blocks. Each block can hold exactly one process. This may waste space if a process is smaller than the partition.
-
Variable Partitioning: The memory is divided based on the actual size of the processes. This is more efficient but can still lead to external fragmentation, where free memory is split into small non-contiguous blocks.
3.1.2 Non-Contiguous Memory Allocation
To overcome fragmentation issues, non-contiguous methods are used, such as:
-
Paging: Memory is divided into fixed-size blocks called pages, and physical memory is divided into frames of the same size. Pages can be loaded into any frame, which eliminates external fragmentation.
-
Segmentation: The process is divided into variable-sized segments like code, data, and stack. Each segment is stored in a different location in memory.
-
Paging with Segmentation: Combines both techniques for more efficient memory use and protection.
3.2. VIRTUAL MEMORY
Virtual memory is a memory management technique that gives an application the illusion it has contiguous working memory while in reality, it may be fragmented or partially stored on disk. This allows the system to run larger applications than the physical memory would normally allow.
3.2.1 Paging and Page Replacement
Virtual memory is typically implemented using paging, where only part of the program is loaded into memory at any time. When the required page is not in memory, a page fault occurs, and the OS loads the needed page from the disk.
-
Page Replacement Algorithms determine which page to remove from memory when space is needed:
-
FIFO (First-In, First-Out): Removes the oldest page.
-
LRU (Least Recently Used): Removes the page that hasn’t been used for the longest time.
-
Optimal Algorithm: Replaces the page that will not be used for the longest future duration (theoretical).
-
3.2.2 Thrashing
Thrashing happens when the OS spends more time swapping pages in and out of memory than executing processes. This leads to a significant drop in performance. It usually occurs when too many processes are competing for limited memory.
Solutions to Thrashing:
-
Reduce the number of running processes.
-
Increase physical memory.
-
Use better page replacement algorithms.