The document provides a comprehensive overview of operating systems, detailing their concepts, functions, types, and the booting process. It covers various services offered by operating systems, including process, memory, and file management, as well as system calls and user management tools. Additionally, it explains process states, process control blocks, and the mechanisms of process scheduling and context switching.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
12 views
os details
The document provides a comprehensive overview of operating systems, detailing their concepts, functions, types, and the booting process. It covers various services offered by operating systems, including process, memory, and file management, as well as system calls and user management tools. Additionally, it explains process states, process control blocks, and the mechanisms of process scheduling and context switching.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19
1.
1 Operating System: Evaluation of Operating System, Concept,
Functions of Operating System Concept of Operating System: An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs. It acts as an intermediary between users and the hardware, enabling the execution of applications efficiently. Evaluation of Operating System: The evolution of operating systems can be traced through several stages: • Early Computers (1940s–1950s): Computers operated without an OS, and programs were loaded manually. • Batch Processing Systems (1950s–1960s): Jobs were processed in batches without user interaction. Example: IBM’s early systems. • Multiprogramming (1960s–1970s): The system could handle multiple programs running simultaneously. • Time-Sharing Systems (1970s–1980s): Multiple users could interact with the system in real-time. • Modern Operating Systems (1990s–present): Include multi-user support, graphical user interfaces (GUIs), real-time processing, mobile OS, and distributed systems. Functions of Operating Systems: • Process Management: Creates, schedules, and terminates processes. • Memory Management: Manages the allocation and deallocation of memory to various applications. • File System Management: Manages files on the disk, including reading, writing, and organization. • Device Management: Handles device communication via drivers. • Security and Access Control: Protects the system’s resources and user data through authentication and permissions. • User Interface: Provides a command-line or graphical interface for user interaction.
1.2 Views of OS: User View, System View
User View: • User Interface (UI): The OS provides an interface for the user to interact with the system, typically a GUI or command-line interface (CLI). • Resource Utilization: From the user's perspective, the OS makes hardware and software resources easy to access and use. Users expect the OS to be responsive and efficient. System View: • Resource Management: The OS acts as a resource manager, coordinating the use of CPU, memory, I/O devices, and storage. • Efficiency: From the system’s viewpoint, the OS must ensure efficient and fair use of resources, managing multitasking, I/O operations, and memory allocation.
1.3 Types of Operating Systems
Batch Operating System: • Jobs are collected and processed in batches without user interaction. • No multitasking, and processing is done sequentially. • Example: Early IBM mainframe systems. Multiprogramming Operating System: • Allows multiple programs to reside in memory at the same time, utilizing CPU efficiently. • The OS switches between programs, allowing overlap in computation and I/O activities. • Example: UNIX. Multitasking Operating System: • Supports running multiple tasks or processes simultaneously on a single CPU. • The CPU switches between tasks so quickly that it appears they are running in parallel. • Example: Windows, Linux. Real-Time Embedded Systems: • These systems require immediate processing and are time- sensitive. • Real-time OS has strict timing constraints and is used in embedded systems. • Example: VxWorks, RTLinux. Multimedia Systems: • These OS handle real-time audio and video data streams. • They are designed to support the recording, playback, and manipulation of multimedia files. • Example: Windows 10, macOS. Distributed Systems: • In a distributed system, multiple computers are networked together, and they work collectively to provide a unified service. • The OS handles resource sharing, task distribution, and communication between systems. • Example: Google File System, Hadoop. Mobile Operating Systems: • Designed for mobile devices such as smartphones and tablets. • These OS are optimized for touch input and limited hardware resources. • Android: Linux-based, used in smartphones. • iOS: Apple's proprietary OS for iPhones and iPads.
1.4 Open-Source Operating System: Linux, BSD Unix
Linux: • Linux is a family of open-source Unix-like operating systems based on the Linux kernel. • Features include multitasking, multi-user capabilities, and a wide range of hardware compatibility. • It is free and highly customizable, making it popular in both server environments and desktop computing. • Example: Ubuntu, Fedora, Debian. BSD Unix: • Berkeley Software Distribution (BSD) Unix is a Unix-like operating system with a focus on performance, stability, and security. • It is open-source and used in various server environments. • Example: FreeBSD, OpenBSD.
1.5 Booting Process of Operating Systems
The booting process is the sequence of operations that the computer performs when it is powered on to load the operating system. Steps in the Booting Process: 1. Power On: The computer receives power, and the hardware components are activated. 2. BIOS/UEFI Execution: The Basic Input/Output System (BIOS) or Unified Extensible Firmware Interface (UEFI) initializes and performs a Power-On Self-Test (POST) to check hardware functionality. 3. Boot Loader Activation: BIOS/UEFI locates the boot loader (e.g., GRUB for Linux, Windows Boot Manager for Windows) from the bootable storage device (HDD, SSD, USB). 4. OS Kernel Load: The boot loader loads the operating system kernel into memory. 5. Kernel Initialization: The kernel initializes system resources, such as memory and CPU, and loads necessary drivers for hardware interaction. 6. User Space Initialization: The OS launches system services (e.g., daemons in Linux) and user interfaces (e.g., login screen). 7. System Ready: Once all processes are running, the OS is ready for user interaction. 2.1 Different Services of Operating System Operating systems provide various services to the users and applications to make system utilization efficient. Some key services include: 1. Program Execution: • The OS manages the execution of programs by loading them into memory, allocating necessary resources, and ensuring smooth execution. • It handles the creation, execution, suspension, and termination of processes. 2. I/O Operations: • The OS manages input/output operations with hardware devices such as keyboards, printers, and storage devices. • It provides device drivers and ensures data is correctly transmitted between applications and I/O devices. 3. File System Management: • The OS provides file management services such as file creation, deletion, reading, writing, and modification. • It organizes files into directories, ensures access control, and handles storage allocation on disk. 4. Memory Management: • The OS handles the allocation and deallocation of memory to various programs. • It manages memory protection and memory sharing between processes. 5. Error Detection: • The OS constantly monitors the system for hardware and software errors. • It provides mechanisms to detect and handle errors, ensuring system stability. 6. Communication Between Processes: • The OS facilitates inter-process communication (IPC) for processes that need to exchange data. • Mechanisms such as shared memory, message passing, or sockets are used to ensure smooth communication between processes. 7. Security and Access Control: • The OS provides security services such as user authentication, password management, and access control. • It protects data and resources from unauthorized access. 8. Resource Allocation: • The OS allocates resources like CPU time, memory, and I/O devices to processes, ensuring fair and efficient usage. 9. User Interface (UI): • The OS provides an interface for users to interact with the system, either through a Command Line Interface (CLI) or a Graphical User Interface (GUI).
2.2 Components of Operating System
1. Process Management: • Definition: The OS manages processes, which are instances of running programs. • Key Functions: o Process creation and termination. o Process scheduling and resource allocation. o Handling process synchronization and communication. • Process States: A process can be in one of the states—new, ready, running, waiting, or terminated. 2. Main Memory Management: • Definition: The OS manages the allocation and deallocation of primary memory (RAM) to various processes. • Key Functions: o Keeps track of each byte in memory. o Allocates memory to processes and deallocates it when no longer needed. o Implements virtual memory techniques to handle large processes. o Ensures memory protection between processes to avoid interference. 3. File Management: • Definition: The OS provides services for the creation, manipulation, and deletion of files. • Key Functions: o Organizes files in directories for easy access. o Manages file permissions and access controls. o Provides mechanisms for file storage and retrieval. o Handles file operations like reading, writing, and updating. 4. I/O System Management: • Definition: The OS manages input/output devices and ensures proper communication between hardware devices and processes. • Key Functions: o Provides device drivers to enable communication with hardware. o Handles input/output buffering to ensure smooth data transfer. o Provides error handling mechanisms for I/O operations. 5. Secondary Storage Management: • Definition: The OS manages secondary storage devices like hard drives, SSDs, and optical disks. • Key Functions: o Provides file system management for storing and retrieving data from secondary storage. o Manages space allocation and defragmentation of storage devices. o Handles backup and recovery mechanisms.
2.3 System Calls: Concept and Types of Operating System Calls
Concept of System Calls: System calls are the interface through which a user program interacts with the operating system. These are low-level functions that allow user-level processes to request services from the OS kernel, such as file manipulation, process control, or network communication. Types of System Calls: 1. Process Control System Calls: o Related to process creation, execution, and termination. o Examples: fork(), exec(), exit(), wait(). 2. File Management System Calls: o Enable file manipulation, such as creating, reading, writing, and deleting files. o Examples: open(), read(), write(), close(), unlink(). 3. Device Management System Calls: o Allow interaction with hardware devices like printers, keyboards, or storage. o Examples: ioctl(), read(), write() (for devices). 4. Information Maintenance System Calls: o Retrieve system information and process data, such as time or process details. o Examples: getpid(), getuid(), time(). 5. Communication System Calls: o Provide mechanisms for inter-process communication (IPC), enabling processes to exchange data. o Examples: pipe(), msgsend(), msgrecv(), shmget(), shmat(). 6. Protection System Calls: o Manage permissions, security settings, and access controls. o Examples: chmod(), chown(), umask().
2.4 Use of Operating System Tools:
1. User Management: • User Creation and Authentication: The OS allows administrators to create, delete, and manage user accounts. It ensures that each user has secure login credentials. • Access Control: The OS provides user groups and permissions to manage file and resource access. For example, in Linux, commands like useradd, passwd, and chown are used for user management. 2. Security Policy: • Authentication Mechanisms: Passwords, multi-factor authentication (MFA), and biometrics help verify user identities. • Access Control: The OS provides mechanisms like file permissions, encryption, and access control lists (ACLs) to ensure data security. • Firewall and Antivirus: Security tools that protect the system from unauthorized access and malware. 3. Device Management: • Device Drivers: The OS includes or installs necessary drivers to communicate with hardware devices. • Device Monitoring: The OS provides utilities for monitoring device health, such as disk usage tools or hardware diagnostic tools. • Plug-and-Play Support: Automatically detects and configures new devices when connected to the system. 4. Performance Monitor: • The OS provides tools to monitor system performance, including CPU usage, memory consumption, disk I/O, and network activity. • Tools: o Windows: Performance Monitor (perfmon), Task Manager. o Linux: Tools like top, htop, vmstat, and iostat. • These tools help detect bottlenecks and optimize performance. 5. Task Manager: • Task Manager: The OS provides a Task Manager (or equivalent) to allow users to view running processes, CPU and memory usage, and terminate unresponsive tasks. • Windows: Task Manager (accessible via Ctrl + Shift + Esc). • Linux: Tools like top or htop provide similar functionality for monitoring and managing processes. 3.1 Process - Process States, Process Control Block (PCB) Process: A process is a program in execution. It consists of the program code, its current activity, and all the resources allocated to it, such as memory, CPU time, and I/O devices. Process States: A process goes through various states during its lifecycle: 1. New: The process is being created. 2. Ready: The process is waiting to be assigned to a CPU. 3. Running: The process is being executed by the CPU. 4. Waiting (Blocked): The process is waiting for some event to occur (e.g., I/O completion). 5. Terminated: The process has finished execution. These states represent different stages in the lifecycle of a process, and the operating system transitions processes between these states as required. Process Control Block (PCB): The Process Control Block is a data structure in the operating system that contains information about a process. It stores all the information necessary for the OS to manage a process, including: • Process ID (PID): A unique identifier for the process. • Process State: The current state of the process (new, ready, running, waiting, terminated). • Program Counter (PC): The address of the next instruction to execute. • CPU Registers: Current values of all the CPU registers. • Memory Management Information: Information about the process’s memory, including base and limit registers or page tables. • Accounting Information: CPU usage, real-time used, process priorities, etc. • I/O Status Information: Information about I/O devices allocated to the process. The PCB allows the OS to manage and schedule processes effectively.
3.2 Process Scheduling - Scheduling Queues, Schedulers, Context
Switch Process Scheduling: Process scheduling is the method by which the operating system decides which process to execute next and allocates CPU time accordingly. Scheduling Queues: Processes move between different queues during their lifecycle: 1. Job Queue: Contains all processes in the system. 2. Ready Queue: Contains processes that are in the ready state, waiting to use the CPU. 3. Waiting (I/O) Queue: Contains processes that are waiting for some I/O operation to complete. Processes are moved between these queues based on their states (e.g., from ready to running, or from waiting to ready). Schedulers: Schedulers are responsible for deciding which process gets CPU time. There are three types of schedulers: 1. Long-Term Scheduler (Job Scheduler): Decides which processes should be loaded from the job queue into the ready queue. It controls the degree of multiprogramming (how many processes are in memory at once). 2. Short-Term Scheduler (CPU Scheduler): Decides which process from the ready queue should be executed next. This scheduler is invoked frequently, making it a fast, efficient component of the OS. 3. Medium-Term Scheduler: Suspends and resumes processes. This is used for processes that are swapped out (moved to secondary storage) to free up memory. Context Switch: A context switch occurs when the CPU switches from executing one process to another. During a context switch: • The state of the current process is saved in its PCB. • The state of the next process to execute is loaded from its PCB. Context switching allows for multitasking but introduces overhead since it involves saving and restoring state information. 3.3 Operations on Processes: Creation, Termination Process Creation: A process can create new processes through a system call (e.g., fork() in UNIX-based systems). The process that creates another process is known as the parent process, and the newly created process is called the child process. • The parent process may duplicate itself (using fork()) or create a new process to run a specific program (using exec()). • Parent and child processes can share resources, or the child may have its own resources. Example: In Linux, when a user starts a new application, the shell creates a new process using fork(). Process Termination: A process terminates when it has finished executing its task. It can be terminated by: 1. Normal Exit: Process completes successfully (e.g., exit() system call). 2. Error Exit: Process encounters an error during execution. 3. Killed by Another Process: A process can be terminated by another process using system calls like kill(). 4. Abnormal Termination: Due to system errors (e.g., hardware failure). When a process terminates, its resources are reclaimed by the operating system, and it is removed from the scheduling queue.
3.4 Inter-Process Communication (IPC): Introduction, Shared
Memory System, and Message Passing System Introduction: Inter-Process Communication (IPC) is a mechanism that allows processes to communicate and synchronize their actions. IPC is essential in multitasking operating systems where processes need to share data or coordinate their execution. Shared Memory System: • In the shared memory model, processes share a section of memory that they can read and write. • It is the fastest IPC mechanism because processes can directly access the shared memory without kernel intervention. • However, synchronization is required (e.g., using semaphores) to prevent race conditions where multiple processes modify the shared memory simultaneously. Example: Two processes communicating via a shared buffer, where one process writes data and the other reads it. Message Passing System: • In the message-passing model, processes communicate by sending and receiving messages via the kernel. • It is slower than shared memory because messages have to be copied from one process to another by the operating system. • Suitable for communication between processes on different machines in a distributed system. • Two types of message-passing systems: o Direct Communication: Processes send and receive messages directly to each other. o Indirect Communication: Processes communicate via a mailbox or message queue. Example: A client-server application where the client sends a request (message) to the server, and the server responds with data.
3.5 Multithreading Models
A thread is the smallest unit of CPU scheduling, and multithreading allows multiple threads to exist within a single process, sharing resources but executing independently. Multithreading Models: 1. Many-to-One Model: o Multiple user-level threads are mapped to a single kernel thread. o The operating system only recognizes the kernel thread, so if one user thread makes a blocking system call, all threads are blocked. o Advantage: Efficient thread management because the kernel is unaware of user-level threads. o Disadvantage: Cannot utilize multiple processors. o Example: Early versions of Sun’s Green Threads for Java. 2. One-to-One Model: o Each user thread is mapped to a separate kernel thread. o Provides better concurrency because the OS can schedule each thread independently. o Advantage: Utilizes multiple processors efficiently. o Disadvantage: Creating a kernel thread for each user thread may cause overhead. o Example: Windows, Linux, and most modern OS implementations. 3. Many-to-Many Model: o Multiple user threads are mapped to multiple kernel threads, allowing the OS to schedule kernel threads across multiple processors. o Advantage: Combines the efficiency of user-level threads with the power of kernel-level threading. o Example: Some Solaris implementations.
3.6 Thread Libraries, Threading Issues
Thread Libraries: Thread libraries provide an API for creating and managing threads. The two main types of thread libraries are: 1. User-Level Libraries: These libraries manage threads in user space without kernel involvement. Examples include: o POSIX Pthreads: A standard API for creating and managing threads, commonly used in UNIX-like systems. o Windows Thread API: A library for creating and managing threads in Windows. o Java Threads: Java provides built-in support for multithreading with the java.lang.Thread class. 2. Kernel-Level Libraries: These libraries manage threads in kernel space, with direct OS support. Threading Issues: 1. Race Condition: o A race condition occurs when multiple threads access shared data simultaneously, and the outcome depends on the order of execution. o Solution: Use synchronization mechanisms like locks or semaphores. 2. Deadlock: o A situation where two or more threads are waiting indefinitely for resources held by each other, causing the program to stall. o Solution: Careful resource management and avoidance of circular waits. 3. Starvation: o A thread is perpetually denied access to resources because other threads are given priority. o Solution: Use priority scheduling algorithms with proper aging mechanisms to prevent starvation. 4. Thread Synchronization: o Synchronization is essential when multiple threads access shared resources. It ensures that only one thread can modify shared data at a time, avoiding inconsistencies. o Tools: Mutexes, semaphores, condition variables, and monitors are commonly used for thread synchronization.