
An operating system (OS) is a software that manages computer hardware and provides common services for computer programs. It acts as an intermediary between the hardware and the user, enabling users to interact with the computer system without needing to know the intricate details of the hardware.
Functions of an operating system include:
Process Management: The OS manages processes, which are programs in execution. It allocates system resources, such as CPU time and memory space, to different processes, and ensures they run efficiently without interfering with each other.
Memory Management: Operating systems handle memory allocation and deallocation. This involves managing both physical memory (RAM) and virtual memory, which allows the OS to use disk space as an extension of RAM when needed.
File System Management: OS provides a file system that organizes and stores data on storage devices such as hard drives. It manages files, directories, and access permissions.
Device Management: Operating systems control input and output devices, such as keyboards, mice, printers, and network adapters. They handle communication between these devices and user applications.
User Interface: Most operating systems provide a user interface (UI) that allows users to interact with the computer system. This can be a command-line interface (CLI) or a graphical user interface (GUI), or both.
Security: OS implements security measures to protect the system and its data from unauthorized access, viruses, and other threats. This includes user authentication, access control, encryption, and antivirus software.
Networking: Operating systems support networking capabilities, allowing computers to communicate with each other over networks. They manage network connections, protocols, and configurations.
The goals of an operating system include:
Efficiency: Operating systems aim to utilize hardware resources efficiently, maximizing performance and minimizing waste. This involves scheduling processes, managing memory effectively, and optimizing disk access.
Reliability: OS should be reliable and robust, providing stable and predictable behavior even under varying conditions. It should handle errors gracefully and recover from failures without compromising system integrity.
Security: Operating systems must ensure the security and privacy of user data and system resources. This involves implementing authentication mechanisms, access controls, and encryption to prevent unauthorized access and malicious attacks.
Ease of Use: OS should be user-friendly and intuitive, allowing users to interact with the system easily and efficiently. This includes providing a simple and consistent user interface, as well as helpful documentation and support resources.
Portability: Operating systems should be portable across different hardware platforms, allowing software to run on various devices without modification. This enables interoperability and flexibility in computing environments.
Overall, the primary goal of an operating system is to provide a stable, efficient, and secure platform for running applications and managing computer resources.
Operating systems can be classified into several types based on various criteria such as the purpose they serve, their design principles, and the platforms they support. Here are some common types of operating systems:
Single-User, Single-Tasking: These operating systems are designed to support only one user and one task at a time. Examples include MS-DOS (Microsoft Disk Operating System) and early versions of Apple's Macintosh operating system.
Single-User, Multi-Tasking: These operating systems allow a single user to run multiple programs simultaneously. Each program runs in its own process, and the OS manages CPU time allocation between them. Examples include Microsoft Windows, macOS, and Linux distributions for desktop computers.
Multi-User: Multi-user operating systems allow multiple users to access the system simultaneously. Each user has their own user account and can run multiple programs independently. Examples include Unix-based systems like Linux and BSD, as well as server versions of Windows.
Real-Time: Real-time operating systems are designed to process data and events within strict time constraints. They are used in applications where timely response is critical, such as industrial automation, robotics, and aerospace systems. Examples include QNX and VxWorks.
Distributed: Distributed operating systems manage a group of independent computers and make them appear as a single coherent system. They provide features such as process migration, distributed file systems, and distributed communication. Examples include Google's Android (based on Linux) and various research projects like Plan 9 from Bell Labs.
Operating systems often provide different modes or levels of operation to ensure system security and stability. The two primary modes are:
Kernel Mode (Privileged Mode): In kernel mode, the operating system has unrestricted access to the hardware and can execute privileged instructions. It has full control over the system resources and can perform critical operations such as memory management, device I/O, and process scheduling. Only trusted system components, such as the kernel and device drivers, run in kernel mode.
User Mode: In user mode, applications and user-level processes run with limited privileges and cannot access hardware directly. They rely on system calls to request services from the operating system kernel. User mode provides a protected environment that prevents user programs from interfering with critical system operations or accessing sensitive resources.
By enforcing a separation between kernel mode and user mode, operating systems ensure system stability, security, and isolation between different processes and user applications.
Mode shifting, interrupts, and system calls are fundamental concepts in operating systems that facilitate communication between user programs and the operating system kernel, as well as handle events and requests efficiently. Let's discuss each of these concepts:
Mode Shifting:
Mode shifting refers to the transition between different privilege levels or execution modes within the CPU. The two primary modes are:
Kernel Mode (Privileged Mode): In kernel mode, the operating system has full access to the hardware and can execute privileged instructions. It can perform critical system operations such as memory management, I/O operations, and process scheduling. Only trusted system components, such as the kernel and device drivers, run in kernel mode.
User Mode: In user mode, applications and user-level processes run with restricted privileges and cannot directly access hardware resources. They rely on system calls to request services from the operating system kernel. User mode provides a protected environment that prevents user programs from interfering with critical system operations or accessing sensitive resources.
Mode shifting occurs when a program transitions between user mode and kernel mode. This transition is typically controlled by hardware mechanisms such as CPU privilege levels and software mechanisms such as system calls and interrupts.
Interrupts:
Interrupts are signals sent by hardware devices or software to the CPU to request attention or notify the CPU of an event that requires immediate processing. Interrupts can be generated by various sources, including hardware devices (e.g., timer interrupts, I/O interrupts), software exceptions (e.g., division by zero, invalid memory access), and system calls initiated by user programs.
When an interrupt occurs, the CPU temporarily suspends the execution of the current program and transfers control to an interrupt handler routine, also known as an interrupt service routine (ISR) or interrupt handler. The interrupt handler then performs the necessary processing to handle the interrupt, which may involve servicing I/O operations, updating system state, or handling errors.
Interrupts are essential for handling asynchronous events efficiently, enabling the operating system to respond promptly to external stimuli without wasting CPU cycles on polling.
System Calls:
System calls are interfaces provided by the operating system that allow user programs to request services and interact with the kernel. They provide a means for user-level processes to access privileged kernel functionality, such as file operations, process management, and network communication.
System calls typically involve a mode shift from user mode to kernel mode, where the operating system kernel executes the requested operation on behalf of the user program. The user program invokes system calls by executing special instructions or software interrupt instructions (e.g., INT 0x80 on x86 architecture) to trigger a mode shift and transfer control to the appropriate kernel routine.
Examples of system calls include opening and closing files, reading and writing data, creating and terminating processes, allocating memory, and performing network operations.
In summary, mode shifting, interrupts, and system calls are essential mechanisms in operating systems that facilitate communication and interaction between user programs and the kernel, enabling efficient resource management, event handling, and service provision.
In the context of computing, "program" and "process" are two related but distinct concepts. Let's differentiate them:
Program:
A program is a set of instructions written in a programming language that performs a specific task or set of tasks when executed.
It is typically a static entity stored on disk or in memory until it is executed.
Examples of programs include word processors, web browsers, video games, and operating system kernels.
Process:
A process, on the other hand, is an instance of a running program.
When a program is executed, it becomes a process, which is a dynamic entity with its own memory space, resources, and execution state.
A process can be seen as a program in execution, including all the data structures and resources required for its execution.
Multiple processes can run concurrently on a computer system, managed by the operating system's process scheduler.
Now, regarding "Process as Abstract Data Type (ADT)":
An abstract data type (ADT) is a theoretical concept in computer science that defines a data type based on its behavior (operations) rather than its implementation details. The concept of a "process" can indeed be treated as an abstract data type in certain contexts, particularly in the field of concurrent and parallel programming.
Here's how you might conceptualize a "Process ADT":
Operations:
Create: Creates a new process.
Destroy: Terminates a process.
Execute: Executes the instructions associated with the process.
Suspend: Temporarily halts the execution of a process.
Resume: Resumes the execution of a suspended process.
Communicate: Processes may communicate with each other through various mechanisms like inter-process communication (IPC).
Properties:
State: A process can be in various states such as running, ready, suspended, or terminated.
Memory Space: Each process has its own memory space, which typically includes code, data, and stack segments.
Resources: Processes may require and utilize system resources such as CPU time, memory, and I/O devices.
By defining the operations and properties of a process in this abstract manner, you can develop algorithms and systems that manipulate processes without needing to be concerned with the low-level details of process management specific to any particular operating system or hardware platform. This abstraction helps in designing and reasoning about concurrent and parallel systems effectively.
Binary Semaphores
This course represents the epitome of comprehensive learning available on this platform, a claim I can confidently stand by. Every effort has been dedicated to delving into the minutiae of the subject matter. Leveraging Numerical and Practice Sessions, I've endeavored to fortify your understanding of OS concepts and foundational principles. The breadth of topics covered is extensive, and even if you possess a rudimentary understanding of OS, you'll undoubtedly appreciate the depth this course explores:
Curriculum :
1. Introduction and Background:
a. Defining an OS:
Elucidated through 5 Definitions
Von Neumann Architecture
Stored Program Concept
Significance of Main Memory
OS as Interface
OS Kernel
OS as Resource Manager
OS as Control Program
b. Types of OS:
Uni-programming and Multiprogramming
Degree of Multiprogramming
Addressing CPU Idleness
Throughput
Schematic View of Multiprogramming
Types of Multiprogramming OS
Comparison between Multiprogramming and Multitasking OS
Architectural Requirements for Implementing Multitasking OS
Kernel & User Mode
c. User and Kernel Mode Shifting:
APIs
Fork system call
Interrupt
ISR
PSW
Types of Functions
Perspective on Mode Shifting
2. Process Management:
a. Understanding Processes:
Distinguishing between program and process
Key C Concepts
7 Definitions of Process
Treating Process as an ADT (Abstract Data Type)
Various Process Operations
Process Attributes and PCB
b. Process Transition Diagram:
Different Process States
Process State Transition Diagram
Introduction to Schedulers and Dispatchers
Addressing Common Doubts
c .Scheduling Queues and State Queuing Diagrams:
Detailed Examination of Schedulers and Dispatchers
Context Switching
3. CPU Scheduling:
a. Introduction and Process Times:
Implementation of Short-Term Schedulers
Functions and Objectives
Understanding Process Times (AT, BT, TAT, IOBT, CT, Schedule Length)
b. FCFS:
Selection Criteria
Operational Mode
Conflict Resolution
Assumptions
Challenges with FCFS Scheduling
Gantt Chart
% CPU Idleness and Efficiency
c. FCFS with Dispatch Latency and IOBT:
Addressing the Most Complex FCFS Problems
Regular Discussion of Home- Work Problems
d. Shortest Job First ( Preemptive and Non Preemptive Case )
Selection Criteria
Operational Mode
Conflict Resolution
Assumptions
Challenges with FCFS Scheduling
Gantt Chart
% CPU Idleness and Efficiency
e. HRRN
f. LRTF
g. Round Robin and Performance Discussion
h. Priority Based Scheduling
i. Multilevel Queue Feedback Scheduling
4.
Process Synchronization / Coordination
IPC and Introduction To Synchronization
Exploring Race Condition
Producer and Consumer Problem Implementation
Which type of Sync in Producer & Consumer Problem ?
Necessary Conditions for Sync Problems
Requirements for Sync Problems
Introduction to Sync Mechanism
Lock Variable - 1
Lock Variable - 2
Lock Variable - 3
Strict Alternation ( Turn Variable )
Implementation of Peterson Solution
Analysis Of Peterson Solution
Homework Question Discussion
Dekker's Algorithm
Introduction to Hardware Solutions
Test & Set Lock
SWAP - Lock and Key
Priority Inversion Problem
Priority Inversion Problem
Solution of Homework Problem
Blocking Mechanisms / Non Busy Wait Solution
Sleep & Wakeup
Producer - Consumer Interesting Case
Semaphores
Counting Semaphores
Binary Semaphores
What about ME, Progress and BW ?
Let's Solve Some Problems
Some More Questions
Some More : )
Producer Consumer - Semaphore Implementation
Some Practice Problems
Reader Writer Problem ( Semaphore )
Dining Philosophers Problem
Parbegin and Parend
Semaphore Solution
Question Practice
Fork & Join
5. Deadlock :
What's Deadlock ?
Resource Allocation Graph
Deadlock Handling Strategies
Resource Allocation Graph Algorithm
Bankers Algorithm
Problem Solving on Bankers Algorithm
Resource Request Algorithm
Problem Solving
Deadlock Detection
Deadlock Recovery
Problem Solving
6. Memory Management
Byte and Word Addressable View
RAM Architecture
Static Vs Dynamic Loading
Static Linking
Dynamic Linking and Address Binding
More about Binding
Memory Management Techniques
Partition Allocation Policy & Variable Partitioning
Problem Solving
Some More Problems
Non Contiguous Allocation
Address Translation
Simple Paging ( Org. of Logical Address Space )
Organization of Physical Address Space
Organization Of Memory Management Unit
How Paging Works ?
Problem Solving
Performance of Paging
Paging Using Cache
Optimal Page Size
Problem Solving
Don't Approximate Here
Hashed Paging
Multilevel Paging
How It's Helpful ?
Addressing In Multilevel Paging
Effective Memory Access Time
Problem Solving
Segmentation
Performance Analysis
Virtual Memory
Demand Paging
Everything in one Flowchart
Problem Solving
Page Replacement
Reference Strings and Page Repl. Algos
Belady's Anomaly
Page Replacement Algorithms
PRA Continued + Problem Solving
Thrashing
The way we write affect thrashing ?
Working Set Model and Locality Of References
7. File Management
Disk Structure
Problem Solving
More Problems
Logical Structure Of The Disk
File Vs Directory
File System Implementation
Allocation Methods
Case Studies
Problem Solving
Disk Free Space Management Algorithm
Problem Solving
More Problems
Disk Scheduling Algorithms
Problem Solving