Unit I: Introduction to Operating System & Process Management
⭐Introduction to Operating System
- 1. Operating System Meaning
- 2. Supervisor & User Mode
- 3. Types of Operating Systems
- 4. OS Structure
- 5. System Calls
- 6. Functions of an Operating System
- 7. Evolution of Operating Systems
- 1. Process Concept
- 2. Process Control Block (PCB)
- 3. Process States
- 4. Operations on Processes
- 5. Cooperating and Independent Processes
- 6. Process Life Cycle
- 7. Process Scheduling
- 8. Context Switching
- 9. Inter-Process Communication (IPC)
- 10. Process Synchronization
- 🚨Thanks for visiting finenotes4u✨
1. Operating System Meaning
An Operating System (OS) is system software that acts as an interface between users and hardware. It manages system resources and provides services for program execution.
1.1 Functions of an OS
- Process Management
- Memory Management
- File System Management
- Device Management
- Security and Access Control
- User Interface (CLI/GUI)
Example OS: Windows, Linux, macOS, Android.
2. Supervisor & User Mode
Modern CPUs operate in two distinct modes to ensure system security and stability:
2.1 User Mode:
- Mode bit = 1 (indicates non-privileged operations).
- Applications and user programs run in this mode.
- Restricted access to system resources.
- Prevents direct hardware access.
2.2 Kernel Mode (Supervisor Mode):
- Mode bit = 0 (indicates privileged operations).
- Allows direct access to hardware.
- Provides services like I/O control, memory management, and process scheduling.
- Executed when a system call is made by a user application.
3. Types of Operating Systems
3.1 Simple Batch Systems
- Jobs are grouped and executed sequentially without user interaction.
- Example: Early IBM batch processing systems.
- Advantage: Efficient for large repetitive tasks.
- Disadvantage: No real-time user interaction.
3.2 Multiprogramming Systems
- Multiple programs reside in memory and share CPU time.
- Example: Unix-based systems.
- Advantage: Increases CPU utilization.
- Disadvantage: Requires complex scheduling.
3.3 Multiprocessing Systems
- Uses multiple CPUs to perform concurrent tasks.
- Example: Modern servers with multi-core processors.
- Advantage: Increases speed and reliability.
- Disadvantage: Expensive hardware requirements.
3.4 Multitasking (Time-Sharing Systems)
- Multiple tasks run by switching the CPU rapidly between them.
- Example: Windows, macOS.
- Advantage: Provides quick response time to users.
- Disadvantage: May cause CPU overhead due to frequent context switching.
3.5 Parallel Operating Systems
- Multiple processors work on a single task simultaneously.
- Used in scientific computing and large-scale computations.
- Advantage: High processing power.
- Disadvantage: Complex programming models.
3.6 Distributed Operating Systems
- A collection of computers act as a single system, sharing resources.
- Example: Cloud-based systems.
- Advantage: Resource sharing and fault tolerance.
- Disadvantage: Requires efficient network management.
3.7 Real-Time Operating Systems (RTOS)
- Used in systems with strict timing constraints.
- Types:
- Hard RTOS: Strict deadlines (e.g., medical devices).
- Soft RTOS: Some flexibility in deadlines (e.g., multimedia applications).
- Advantage: Predictable response time.
- Disadvantage: Limited multitasking capability.
4. OS Structure
Operating systems are structured to organize their functionalities efficiently.
4.1 Types of OS Structures
Monolithic Structure:
- All OS components are tightly integrated.
- Example: Traditional Unix.
Layered Structure:
- OS is divided into layers, each providing specific functionality.
- Example: THE operating system.
Microkernel Structure:
- Minimal OS functionality, additional services run in user space.
- Example: QNX, Windows NT.
Modular Structure:
- OS divided into dynamically loadable modules.
- Example: Linux kernel modules.
5. System Calls
System calls provide an interface between user applications and OS services.
5.1 Types of System Calls
- Process Control: Start, stop, terminate processes (
fork()
,exec()
). - File Management: Open, read, write files (
open()
,read()
). - Device Management: Request and release devices (
ioctl()
). - Information Maintenance: Get system information (
getpid()
). - Communication: Exchange data between processes (
send()
,recv()
).
Example: In Linux, system calls are accessed via libraries like libc
.
6. Functions of an Operating System
6.1 Process Management:
- Creation, scheduling, and termination of processes.
- Example: Multi-user multitasking in Linux.
6.2 Memory Management:
- Allocation and deallocation of memory spaces.
- Example: Virtual memory and paging systems.
6.3 File Management:
- Organizing, storing, and accessing files.
- Example: FAT32, NTFS file systems.
6.4 Device Management:
- Managing input/output devices via device drivers.
- Example: Printer, keyboard handling.
6.5 Security and Protection:
- Preventing unauthorized access to system resources.
- Example: User authentication and encryption.
6.6 User Interface:
- Providing interaction between the user and the OS.
- Example: Command Line Interface (CLI), Graphical User Interface (GUI).
7. Evolution of Operating Systems
7.1 First Generation (1940s-1950s):
- No OS, programs executed manually using punch cards.
- Example: ENIAC.
7.2 Second Generation (1950s-1960s):
- Batch processing systems introduced.
- Example: IBM mainframes.
7.3 Third Generation (1960s-1970s):
- Introduction of multiprogramming and time-sharing.
- Example: Unix OS.
7.4 Fourth Generation (1980s-1990s):
- GUI-based personal computers (PCs).
- Example: Windows 95.
7.5 Fifth Generation (2000s-Present):
- Mobile computing, cloud computing, virtualization.
- Example: Android, iOS, AWS Cloud.
⭐Process Management
1. Process Concept
A process is a program in execution. It consists of:
- Code Section (Text Section): Program instructions.
- Program Counter (PC): Tracks the next instruction to execute.
- Stack: Stores temporary data (function calls, local variables).
- Heap: Dynamic memory allocation.
- Data Section: Global variables.
1.1 Difference Between Program and Process:
Program (Passive) | Process (Active) |
---|---|
Stored on disk | Loaded in memory |
No execution | Actively executed by CPU |
Static | Dynamic (changes state) |
2. Process Control Block (PCB)
A PCB is a data structure used by the OS to store information about a process.
2.1 Information Contained in PCB:
- Process ID (PID): Unique identifier for the process.
- Process State: New, Ready, Running, Waiting, Terminated.
- Program Counter: Address of the next instruction.
- CPU Registers: Current values of CPU registers.
- Memory Management Info: Base/limit registers, page tables.
- I/O Status Info: List of allocated I/O devices.
- CPU Scheduling Info: Priority, scheduling queue pointers.
- Accounting Info: CPU time used, process execution time.
3. Process States
A process goes through several states during its lifetime.
3.1 Types of Process States:
- New: The process is created and waiting to be admitted.
- Ready: Process is ready to run but waiting for CPU allocation.
- Running: The process is currently executing.
- Waiting (Blocked): Process waiting for I/O or an event.
- Terminated (Exit): The process has completed execution.
3.2 State Transition Diagram:
4. Operations on Processes
The OS performs several operations to manage processes efficiently:
Process Creation:
- Done using system calls like
fork()
. - Parent process spawns child processes.
- Done using system calls like
Process Execution:
- Process runs in CPU under scheduling policies.
Process Suspension:
- Process is moved from running to waiting (I/O request).
Process Termination:
- Process ends execution normally or abnormally (e.g., errors).
5. Cooperating and Independent Processes
5.1 Independent Processes:
- Do not share data with other processes.
- Execution of one process does not affect others.
- Example: Multiple browser tabs running separately.
5.2 Cooperating Processes:
- Share data and resources.
- Require synchronization mechanisms (shared memory, message passing).
- Example: Web applications accessing shared databases.
Advantages of Process Cooperation:
- Information Sharing: Shared resources such as files.
- Computation Speedup: Parallel execution.
- Modularity: Easier to maintain and develop applications.
- Convenience: Users can run multiple tasks simultaneously.
6. Process Life Cycle
A process moves through different stages during its lifetime.
6.1 Steps in Process Life Cycle:
- Process Creation: OS loads program into memory.
- Ready State: Process waits for CPU.
- Running State: CPU executes the process.
- Waiting State: Process waits for I/O.
- Terminated State: Process completes and OS deallocates resources.
7. Process Scheduling
Scheduling decides which process runs at a given time to maximize CPU efficiency.
7.1 Types of Scheduling:
Long-Term Scheduling:
- Decides which jobs enter the system.
- Manages degree of multiprogramming.
Short-Term Scheduling:
- Selects a process from the ready queue for execution.
- Frequently executed to allocate CPU time.
Medium-Term Scheduling:
- Suspends processes to reduce memory load (swapping).
8. Context Switching
When switching from one process to another, the OS saves and restores process states.
8.1 Steps in Context Switching:
- Save the current process state in the PCB.
- Load the next process state from its PCB.
- Update CPU registers and memory management structures.
Context Switch Overhead: Switching takes CPU time and affects performance.
9. Inter-Process Communication (IPC)
IPC is used for communication between cooperating processes.
9.1 IPC Mechanisms:
Shared Memory:
- Processes share a common memory space.
- Fast but requires synchronization.
Message Passing:
- Processes send and receive messages via the OS.
- Easier in distributed systems but slower.
Synchronization Techniques: Semaphores, Mutexes, Pipes, Sockets.
10. Process Synchronization
When multiple processes access shared data, synchronization is needed to prevent conflicts.
10.1 Issues in Process Synchronization:
- Race Condition: Multiple processes modify shared data concurrently.
- Deadlock: Two or more processes wait indefinitely.
- Starvation: Process waits indefinitely due to resource priority.
Solutions: Locks, Semaphores, Monitors.
🚨Thanks for visiting finenotes4u✨
Welcome to a hub for 😇Nerds and knowledge seekers! Here, you'll find everything you need to stay updated on education, notes, books, and daily trends.
💗 Bookmark our site to stay connected and never miss an update!
💌 Have suggestions or need more content? Drop a comment below, and let us know what topics you'd like to see next! Your support means the world to us. 😍
‼️cse408, int428 & pea305 ?