Operating System Notes PDF

Summary

This document provides notes on operating system concepts. It covers topics such as process management, memory management, and file systems.

Full Transcript

# Operating System Notes ## Goals of Operating System - Control the use of system resources such as memory, I/O devices, and files. - Provide a convenient environment for users to access available resources. - Increase the productivity of processes. - Use computer hardware efficiently. ## Kernel an...

# Operating System Notes ## Goals of Operating System - Control the use of system resources such as memory, I/O devices, and files. - Provide a convenient environment for users to access available resources. - Increase the productivity of processes. - Use computer hardware efficiently. ## Kernel and Shell - **Kernel:** The core part of the operating system that directly interacts with the user. - **Shell:** The user interface that allows interaction with the operating system. ## Process States - New - Waiting - Ready - Terminated ## Race Condition - A race condition occurs when two or more processes share resources, such as file or memory, simultaneously which can lead to unpredictable system behavior. ## Swapping - Swapping in an operating system is the process of moving data between physical memory and secondary memory. ## Seek Time and Transfer Time - **Seek Time:** The time taken by a disk's read/write head to move to the data. - **Transfer Time:** The time taken to transfer data from the disk to memory. ## Operating System Functions - Process Management - File Management - Memory Management - I/O Device - Security - Networking - Command Interpreter - System ## Deadlock - A situation where two or more processes are waiting for each other to release resources. This situation results in a deadlock where no progress can be made. ## Example of Deadlock - Process A holds Resource 1 and needs Resource 2 to continue. - Process B holds Resource 2 and needs Resource 1 to continue. ## Page Fault and Fragmentation - **Page Fault:** Occurs when a requested page is not available in memory. - **Fragmentation:** Occurs when available memory is fragmented into small pieces making efficient use of memory difficult. ## Types of Files - Ordinary File - Directory File - Special File ## Disk Formatting - The process of preparing a data storage device such as hard disk drive or memory card. ## Process Control Block - A data structure used by the operating system to store information about a specific process. ## Thread - A lightweight process that is either smaller or larger than a process. Requires less resources from the operating system to run and takes less time to switch contexts. ## Pooling - A technique in an operating system that temporarily stores data for a device, program, or system to use. ## File Attributes - Name - Identifier - Type - Location - Size - Protection - Time and Date ## Tracks and Sectors - **Tracks:** A circular path on the surface of a disk where data is stored. - **Sectors:** A smaller division within a track. Each track is divided into sectors. ## Security in Operating System - The operating system protects data by using passwords and it protects user data and techniques. ## Types of Viruses - Boot sector viruses - File infector viruses - Macro viruses - Trojan horses - Worms ## CPU Scheduling - The process of deciding which program should use the computer's CPU at a given time. ## Synchronization - The way in which processes that share the same memory space are managed in an operating system. ## Semaphore - A variable in an operating system that controls access to shared resources by multiple processes. ## Critical Section Problem - Occurs when multiple processes try to access and modify the same shared data or resources at the same time. ## Examples of Critical Section Problem - **Two people writing on the same document simultaneously.** - **Two processes trying to update a bank account balance.** ## Methods for Handling Deadlock - Ignoring the issue - Detection and Recovery - Deadlock Avoidance - Prevention ## Deadlock Avoidance - Carefully allocating resources to processes to prevent the system from reaching a deadlock state. ## Recovery from Deadlock - The process of breaking a deadlock after it has already occurred. The system detects the deadlock and takes steps to resolve it. ## Segmentation - A memory management technique where a process is divided into smaller logical parts called Segments. ## Virtual Memory - A technique that enables the computer system to manage storage space to keep systems running quickly and efficiently. ## Demand Paging - A memory management technique in an operating system that copies a page from disk into physical memory and is also called Lazy Swapping. ## Page Replacement - A memory management technique that decides which page in physical memory should be replaced. ## Different Disk scheduling Algorithms - First Come First Served (FCFS) - Shortest Seek Time First (SSTF) - SCAN - LOOK - C-SCAN - C-LOOK ## What is Paging? - A memory management technique in an operating system that divides the physical memory into fixed-sized blocks called frames and the logical memory into equal fixed-sized blocks called pages. ## Advantages of Paging - Efficient Memory Utilization - Simple Allocation - Supports Virtual Memory - Process Isolation ## Disadvantages of Paging - Internal Fragmentation - Overhead of Page Table - Page Fault - Increased Latency ## Functions and Components of Operating System - **Process Management:** Controls the execution of multiple programs simultaneously. Includes tasks like creation, deletion, and scheduling. - **File Management:** Organizes and manages data on storage devices. Responsible for creating, deleting, reading, and writing files, as well as providing access to files. - **Memory Management:** Allocates and manages the computer's main memory (RAM). Responsible for allocating memory to processes, ensuring that processes have enough memory to run without interfering with each other. - **I/O Device Management:** Handles communication between the computer system and peripheral devices, such as keyboard, printer, and hard drive. Manages the access and use of these devices. - **Security:** Protects the system from unauthorized access, including data breaches and security threats. Controls user access levels and permissions, enforces authentication mechanisms, and safeguards sensitive information. - **Networking:** Enables communication between computers connected over a network. Enables systems to be connected to a wide range of networks, including the internet. - **Command Interpreter:** Processes user commands and interprets them into actions that the operating system can perform. Used for tasks such as running programs, creating files, and navigating your file system. ## Explain Different States Of A Process - **New:** Process has just been created. - **Ready:** Process is ready to run but waiting for CPU allocation. - **Running:** Process is currently running on the CPU. - **Waiting:** Process is waiting for an event (like I/O completion) to occur. - **Terminated:** Process has finished execution. ## Process Control Block (PCB) - A data structure that keeps track of information about a process. The operating system needs this information to manage the process. - **Attributes:** - Process ID: Identifies the process uniquely. - Program Counter: Points to the next instruction to be executed. - CPU Registers: Stores data about the process, such as the values of the CPU registers. - Memory Management Information: Data about how the process's memory is organized in relation to the operating system. - I/O Status: Information on the status of the process's I/O operations. ## System Call - A special instruction called by a program when it needs to access a service or functionality provided by the operating system. The operating system kernel handles the request. ## Types of System Calls - **Process Control:** Creation, deletion, and management of processes. - **File Management:** Create, delete, open, and close files. - **Device Management:** Access and control hardware devices. - **Information Maintenance:** Maintain system information, such as date and time. - **Communication:** Allow processes to communicate with each other. - **Protection:** Enforce security measures to protect privileged resources. ## Methods for Preventing Deadlock - Prevent Mutual Exclusion - Breaking Circular Waits - Preemption - Avoiding Deadlock <start_of_image> ## Deadlock Avoidance - A deadlock avoidance technique that involves allocating resources to processes in a way that ensures a deadlock situation will never occur. ## Different Types of Fragmentation - **Internal Fragmentation**: Unused space inside a block that can't be used. - **External Fragmentation**: Free memory blocks are not large enough to fulfill a process's requirement even though there is enough free space overall. ## Demand Paging - A page replacement technique that loads pages into the memory only when they are needed. - This technique minimizes memory usage and increases performance. ## Page Replacement Algorithms - **First In First Out (FIFO):** The page that is loaded first is replaced first. - **Least Recently Used (LRU):** The page that was used least recently is replaced. ## Benefits of Demand Paging - Reduced memory usage - Faster program loading ## Disk Scheduling Algorithm - **First Come First Served (FCFS):** The request that comes first is served first. - **Shortest Seek Time First (SSTF):** The request closest to the current head position is served first. - **SCAN:** The head moves in one direction, servicing requests along the way, then reverses direction and continues processing the requests. - **LOOK:** Similar to SCAN, but the head only moves to the last request in the direction it's heading, then reverses direction. - **C-SCAN:** The head scans in one direction, but then moves to the other end of the disk and continues scanning. The process then repeats. - **C-LOOK:** Similar to C-SCAN, but the head only moves to the last request in the direction it's heading. The process then reverses direction. ## What is Booting? - The process of starting up a computer system and loading the operating system. ## Types of Booting - **Cold Boot:** The system starts from scratch, and the operating system must be loaded completely. This is the process that happens after power cycling the computer. - **Warm Boot:** The system reboots while the operating system is already loaded. This is done through restarting the system without power cycling it. ## Multithreading - A programming model that creates multiple threads of execution within a single process. ## Advantages of Multithreading - **Concurrency:** Allows for more than one task to be processed concurrently. - **Shared Resources:** Threads in a single process share the same memory space. - **Faster Execution:** Threads can potentially improve performance. ## Directory Structures - A hierarchical way to organize and store files and folders in a computer system. ## Types of Directories - **Root Directory:** The topmost directory in a hierarchical directory structure. - **Sub-directories:** Directories that are located within another directory. ## Path - A sequence of directories that lead to a specific file or folder. - There are two types of paths: - **Absolute Path:** Begins at the root directory. - **Relative Path:** Begins at the current working directory. ## Linux Operating System - An open-source operating system known for its stability, flexibility, and security. - Used on a wide range of devices such as servers, desktops, smartphones, and embedded systems. - Developed by Linus Torvalds in 1991. ## Features of Linux - **Open Source:** The source code of Linux is available to the public, allowing anyone to view, modify, and distribute it. - **Multi-User:** Supports multiple users to access and use the operating system simultaneously. - **Multitasking:** Able to run and manage multiple tasks concurrently. - **Security:** Offers a more secure environment compared to other operating systems, such as Windows. - **Customizable:** Can be customized to meet specific requirements, making it a popular choice for developers and system administrators. ## Booting Types - **Cold Boot:** System starts from scratch, loading the operating system completely. - **Warm Boot:** System reboots, but the operating system remains loaded. ## File Allocation Methods - **Contiguous Allocation:** Allocates contiguous blocks of disk space for each file. - **Linked Allocation:** Files are stored in a linked list, with each block containing pointers to the next block. - **Indexed Allocation:** A table in the disk stores pointers to the blocks where a file is stored. ## Banker’s Algorithm - A deadlock avoidance algorithm that allows resources to be allocated dynamically to processes while ensuring that a deadlock situation will never occur. ## How Banker's Algorithm Works - **Maximum Need:** Each process declares the maximum number of resources it requires. - **Current Allocation:** The amount of each resource currently allocated to each process. - **Available Resources:** The total number of resources available in the system. ## Safety Check - The algorithm checks whether it is safe to allocate resources to processes. It considers whether the system can still satisfy future requests from other processes without leading to a deadlock. ## Advantages of Banker’s Algorithm - **Deadlock Avoidance:** Prevents deadlocks from occurring. - **Resource Utilization:** Helps in efficient use of resources by allocating them to processes that need them. - **Flexibility:** Allows for dynamic allocation of resources. ## Disadvantages of Banker’s Algorithm - **Overhead:** Requires additional overhead to track resource allocation information. - **Limited Applicability:** May not be suitable for all systems or scenarios, especially those involving real-time processes or with high resource contention. ## CPU Scheduling Algorithms - First Come First Served (FCFS): Processes are served in the order they arrive. - Shortest Job First (SJF): This algorithm prioritizes the process with the shortest estimated burst time first. - Priority Scheduling: Processes are assigned priorities, with higher priority processes being served first. - Round Robin: A time-sharing algorithm where each process gets a fixed time quantum or time slice to run. - Multi-Level Queue: Processes are divided into multiple queues based on their characteristics. ## Directory Structures - A hierarchical way to organize and store the files and folders present in a computer system. A tree-like structure is used to represent it. ## Types of Directories - **Root Directory:** The main directory from which all other directories are derived. - **Sub-directories:** Directories that are located within another directory. ## Path - A sequence of directories that lead to specific file or folder, like a road map. - * **Absolute Path:** Starts from the root directory. - * **Relative Path:** Starts at the current directory. ## Linux Operating System - A popular, open-source operating system known for its stability, flexibility, and security. ## Features of the Linux Operating System - **Open Source:** The source code is freely available for anyone to view, modify, and distribute. - **Multi-User:** Multiple users can access and use the system concurrently. - **Multitasking:** Allows for running and managing multiple tasks simultaneously. - **Security:** Considered more secure compared to other operating systems, such as Windows. - **Customizable:** Highly customizable, allowing users to tailor it to their specific needs. This is particularly attractive to developers and system administrators. ## Booting Types - **Cold Boot:** The system starts completely afresh, loading the operating system from scratch. This typically occurs on a complete power cycle. - **Warm Boot:** The system restarts, but the operating system remains loaded. This can be done via a system restart without a complete power cycle. ## File Allocation Methods - **Contiguous Allocation:** Each file is allocated a contiguous block of space on the disk. - **Linked Allocation:** Files are stored in a linked list, where each block points to the next block in the chain. - **Indexed Allocation:** A table is maintained on disk that contains entries pointing to the different blocks where the file is stored.

Use Quizgecko on...
Browser
Browser