🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

**What is an Operating System?** - A program that acts as an intermediary between a user of a computer and the computer hardware. - An operating System is a collection of system programs that together control the operations of a computer system. - Some examples of operating systems...

**What is an Operating System?** - A program that acts as an intermediary between a user of a computer and the computer hardware. - An operating System is a collection of system programs that together control the operations of a computer system. - Some examples of operating systems are UNIX, Mach, MS-DOS, MS-Windows, Windows/NT, Chicago, OS/2, MacOS, VMS, MVS, and VM. **Operating system goals:** - Execute user programs and make solving user problems easier. - Make the computer system convenient to use. - Use the computer hardware in an efficient manner. **Computer System Components** **1. Hardware** -- provides basic computing resources (CPU, memory, I/O devices). **2. Operating system** -- controls and coordinates the use of the hardware among the various application programs for the various users. **3. Applications programs** -- Define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs). **4. Users** - (people, machines, other computers). **Operating System Definitions** **Resource allocator** -- manages and allocates resources. **Control program** -- controls the execution of user programs and operations of I/O devices. **Kernel** -- The one program running at all times (all else being application programs). **Components of OS**: OS has two parts. **(1)Kernel.(2)Shell.** **(1) Kernel** is an active part of an OS i.e., it is the part of OS running at all times. It is a programs which can interact with the hardware. Ex: Device driver, dll files, system files etc. **(2) Shell** is called as the command interpreter. It is a set of programs used to interact with the application programs. It is responsible for execution of instructions given to OS (called commands). **Operating systems can be explored from two viewpoints:** the user and the system. **User View:** From the user's point view, the OS is designed for one user to monopolize its resources, to maximize the work that the user is performing and for ease of use. **System View:** From the computer\'s point of view, an operating system is a control program that manages the execution of user programs to prevent errors and improper use of the computer. It is concerned with the operation and control of I/O devices. **Functions of Operating System:** - **Process Management** A **process** is a program in execution. A process needs certain resources, including CPU time, memory,files, and I/O devices, to accomplish its task. The operating system is responsible for the following activities in connection with process management. ✦ Process creation and deletion. ✦ process suspension and resumption. ✦ Provision of mechanisms for: - process synchronization - process communication - **Main-Memory Management** Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices. Main memory is a volatile storage device. It loses its contents in the case of system failure. The operating system is responsible for the following activities in connections with memory management: - Keep track of which parts of memory are currently being used and by whom. - Decide which processes to load when memory space becomes available. - Allocate and de-allocate memory space as needed. - **File Management** A file is a collection of related information defined by its creator. Commonly, files represent programs(both source and object forms) and data. The operating system is responsible for the following activities in connections with file management: ✦ File creation and deletion. ✦ Directory creation and deletion. ✦ Support of primitives for manipulating files and directories. ✦ Mapping files onto secondary storage. ✦ File backup on stable (nonvolatile) storage media - **I/O System Management** The I/O system consists of: ✦ A buffer-caching system ✦ A general device-driver interface ✦ Drivers for specific hardware devices - **Secondary-Storage Management** Since main memory (primary storage) is volatile and too small to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory. Most modern computer systems use disks as the principle on-line storage medium, for both and data. The operating system is responsible for the following activities in connection with disk management: ✦ Free space management ✦ Storage allocation ✦ Disk scheduling - **Networking (Distributed Systems)** - A distributed system is a collection processors that do not share memory or a clock. Each processor has - its own local memory. - The processors in the system are connected through a communication network. - Communication takes place using a protocol. - A distributed system provides user access to various system resources. - Access to a shared resource allows: - Computation speed-up - Increased data availability - Enhanced reliability - **Protection System** Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources. The protection mechanism must: ✦ distinguish between authorized and unauthorized usage. ✦ specify the controls to be imposed. ✦ provide a means of enforcement. - **Command-Interpreter System** Many commands are given to the operating system by control statements which deal with: ✦ process creation and management ✦ I/O handling ✦ secondary-storage management ✦ main-memory management ✦ file-system access ✦ protection ✦ networking - The program that reads and interprets control statements is called variously: ✦ command-line interpreter ✦ shell (in UNIX) - Its function is to get and execute the next command statement. - **Operating-System Structures** - System Components - Operating System Services - System Calls - System Programs - System Structure - Virtual Machines - System Design and Implementation - System Generation - **Common System Components** - Process Management - Main Memory Management - File Management - I/O System Management - Secondary Management - Networking - Protection System - Command-Interpreter System **Definition of my teacher discuss:** **Stack -** In the document, a stack is described as a data structure used to implement the Least Recently Used (LRU) page replacement algorithm. It maintains a list of page numbers where the most recently used page is at the top and the least recently used page is at the bottom. The stack is best implemented using a doubly linked list, allowing efficient updates when pages are referenced. **Data Section -** The Data Section in the document refers to a segment of a program\'s memory that contains global and static variables. This section is used to store data that persists for the duration of the program\'s execution, including initialized and uninitialized variables. It is distinct from other sections like the code section, which contains the executable instructions of the program. **Heap -** The heap is a data structure used for dynamic memory allocation in computer programs. - In the context of memory management, heap refers to the part of the memory where dynamic memory allocation occurs. - The heap is used for allocating memory blocks of varying sizes during program execution. - Fragmentation can occur in the heap due to the wasting of memory space, leading to inefficiencies **Process Concept** - Informally, a process is a program in execution. A process is more than the program code, which is sometimes known as the text section. It also includes the current activity, as represented by the value of the program counter and the contents of the processor\'s registers. In addition, a process generally includes the process stack, which contains temporary data (such as method parameters, return addresses, and local variables), and a data section, which contains global variables. - An operating system executes a variety of programs: ✦ **Batch system** -- jobs ✦ **Time-shared systems** -- user programs or tasks - **Process** -- a program in execution; process execution must progress in sequential fashion. - A process includes: **program counter , stack, data section** 1. **The Process State** - refers to the current status of a process as it executes. As a process runs, it changes state, and the document outlines several key states: **New State:** The process is being created. **Running State:** The process is currently being executed by the CPU. **Blocked (or Waiting) State:** The process is waiting for some event to occur, such as the completion of an I/O operation. **Ready State:** The process is ready to run and is waiting for CPU availability. **Terminated State:** The process has finished its execution​ **What is the difference between process and program?** 1\) Both are same beast with different name or when this beast is sleeping (not executing) it is called program and when it is executing becomes process. 2\) Program is a static object whereas a process is a dynamic object. 3\) A program resides in secondary storage whereas a process resides in main memory. 4\) The span time of a program is unlimited but the span time of a process is limited. 5\) A process is an \'active\' entity whereas a program is a \'passive\' entity. 6\) A program is an algorithm expressed in programming language whereas a process is expressed in assembly language or machine language. 2. **Program counter:** The counter indicates the address of the next instruction to be executed for this process 3. **CPU registers:** The registers vary in number and type, depending on the computer architecture. They include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code information. Along with the program counter, this state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward. 4. **CPU-scheduling information:** This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters. 5. **Memory-management information:** This information may include such information as the value of the base and limit registers, the page tables, or the segment tables, depending on the memory system used by the operating system. 6. **Accounting information:** This information includes the amount of CPU and real time used, time limits, account numbers, job or process numbers, and so on. 7. **I/O status information:** he information includes the list of I/O devices allocated to this process, a list of open files, and so on. The PCB simply serves as the repository for any information that may vary from process to process. **NEXT...** 1. **THREAD -** A thread, sometimes called a lightweight process (LWP), is a basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack. It shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals. A traditional (or heavyweight) process has a single thread of control. If the process has multiple threads of control, it can do more than one task at a time. **Process Scheduling Queues** - **Job Queue:** This queue consists of all processes in the system; those processes are entered to the system as new processes. - **Ready Queue:** This queue consists of the processes that are residing in main memory and are ready and waiting to execute by CPU. This queue is generally stored as a linked list. A ready-queue header contains pointers to the first and final PCBs in the list. Each PCB includes a pointer field that points to the next PCB in the ready queue. - **Device Queue:** This queue consists of the processes that are waiting for a particular I/O device. Each device has its own device queue. **Schedulers** A scheduler is a decision maker that selects the processes from one scheduling queue to another or allocates CPU for execution. The Operating System has three types of scheduler: 1\. **Long-term scheduler or Job scheduler** 2\. **Short-term scheduler or CPU scheduler** 3\. **Medium-term schedule** 1. **Long-term scheduler or Job scheduler** - The long-term scheduler or job scheduler selects processes from discs and loads them into main memory for execution. It executes much less frequently. - It controls the degree of multiprogramming (i.e., the number of processes in memory). - Because of the longer interval between executions, the long-term scheduler can afford to take more time to select a process for execution 2. **Short-term scheduler or CPU scheduler** - The short-term scheduler or CPU scheduler selects a process from among the processes that are ready to execute and allocates the CPU. - The short-term scheduler must select a new process for the CPU frequently. A process may execute for only a few milliseconds before waiting for an I/O request. 3. **Medium-term scheduler** - The medium-term scheduler schedules the processes as intermediate level of scheduling Processes can be described as either: ✦**I/O-bound process** -- spends more time doing I/O than computations, many short CPU bursts. ✦**CPU-bound process** -- spends more time doing computations; few very long CPU bursts. **Context Switch** - When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. - Context-switch time is overhead; the system does no useful work while switching. **Process Creation** Parent process create children processes, which, in turn create other processes, forming a tree of processes. **Resource sharing:** ✦ Parent and children share all resources. ✦ Children share subset of parent's resources. ✦ Parent and child share no resources. **Execution:** ✦ Parent and children execute concurrently. ✦ Parent waits until children terminate. **Address space:** ✦ Child duplicate of parent. ✦ Child has a program loaded into it. UNIX examples ✦ **fork** system call creates new process ✦ **exec** system call used after a **fork** to replace the process' memory space with a new program. **Process Termination** - Process executes last statement and asks the operating system to decide it **(exit).** ✦ Output data from child to parent **(via wait).** ✦ Process' resources are deallocated by operating system. - Parent may terminate execution of children processes (abort). ✦ Child has exceeded allocated resources. ✦ Task assigned to child is no longer required. ✦ Parent is exiting. ✔ Operating system does not allow child to continue if its parent terminates. ✔ Cascading termination **Dispatcher** - The dispatcher is a module that gives control of the CPU to the process selected by the short-term scheduler. It involves switching context, switching to user mode, and jumping to the appropriate location in the user program to restart execution. **Dispatch Latency** - Dispatch latency refers to the time it takes for the dispatcher to stop one process and start another. **Scheduling Criteria** - CPU utilization -- keep the CPU as busy as possible - Throughput -- \# of processes that complete their execution per time unit - Turnaround time -- amount of time to execute a particular process - Waiting time -- amount of time a process has been waiting in the ready queue - Response time -- amount of time it takes from when a request was submitted until the first response is - produced, not output (for time-sharing environment **First-Come, First-Served Scheduling** - First-Come, First-Served (FCFS) scheduling is the simplest CPU scheduling algorithm where the process that requests the CPU first is allocated the CPU first, managed using a FIFO queue. While easy to implement and understand, FCFS often results in long average waiting times, especially in time-sharing systems where it can lead to one process monopolizing the CPU. This can be problematic as it does not allow for regular CPU access for all users. **Shortest-Job-First Scheduling** - Shortest-Job-First (SJF) scheduling is a CPU scheduling algorithm that assigns the CPU to the process with the smallest next CPU burst time. It can be either preemptive or non preemptive, with preemptive SJF allowing a new process with a shorter burst to interrupt the currently running process. SJF is optimal in minimizing average waiting time, but it faces challenges in accurately predicting the next CPU burst length. **Shortest Remaining Time** - Shortest Remaining Time (SRT) is a preemptive version of the Shortest-Job-First (SJF) scheduling algorithm. In SRT, if a new process arrives with a shorter remaining CPU burst time than the currently executing process, the CPU is preempted and allocated to the new process. This approach aims to minimize average waiting time by always executing the process with the least remaining time first. **Priority Scheduling** - Priority scheduling is a CPU scheduling algorithm that assigns the CPU to processes based on their priority levels, with higher priority processes being executed before lower priority ones. It can be either preemptive, where a running process can be interrupted if a new process with a higher priority arrives, or nonprimitive, where the running process continues until completion. A key issue with priority scheduling is the potential for indefinite blocking or starvation of low-priority processes. **Round-Robin Scheduling** - Round-Robin (RR) scheduling is a preemptive CPU scheduling algorithm designed for time-sharing systems, where each process is assigned a fixed time slice or quantum to execute. The ready queue is treated as a circular queue, and the CPU scheduler allocates the CPU to each process for a time interval of up to one time quantum, ensuring that no process monopolizes the CPU. The performance of RR heavily depends on the size of the time quantum, balancing between responsiveness and overhead. **CPU Burst** - CPU burst refers to the time a process spends executing on the CPU before it either completes or requires I/O operations. Processes typically alternate between CPU bursts and I/O bursts, with CPU-bound processes having longer bursts and I/O-bound processes having shorter bursts. Understanding CPU burst distribution is crucial for effective CPU scheduling and optimizing system performance. **Multiple Choice Questions** 1. **What is an Operating System?** - **b) A collection of system programs that controls computer operations.** 2. **Which of the following is NOT an example of an operating system?** - **c) Chrome Browser** 3. **The Operating System acts as an intermediary between:** - **b) The user and the computer hardware.** 4. **Which component of the computer system is responsible for managing hardware among various application programs?** - **c) Operating System** 5. **Which of the following is NOT a goal of an Operating System?** - **d) Manufacture hardware components.** 6. **Which process scheduling queue contains processes that are ready and waiting to execute?** - **c) Ready Queue** 7. **What is the role of the Medium-term scheduler?** - **c) To handle the intermediate level of process scheduling.** 8. **What is a stack used for in the context of memory management?** - **b) To implement the Least Recently Used (LRU) page replacement algorithm.** 9. **What is the function of the Kernel in an Operating System?** - **d) To act as the main program running at all times.** 10. **Which of the following is a function of the Protection System in an OS?** - **c) Controlling access to system and user resources** **True or False** 1. **A process is a static object, while a program is a dynamic object.** - **False** (The correct statement is that a program is a static object, while a process is a dynamic object.) 2. **The Shell is responsible for interacting with the hardware directly.** - **False** (The Kernel interacts with hardware; the Shell interprets user commands.) 3. **Context switching refers to the time during which the system switches from one process to another, and no useful work is done during this time.** - **True** 4. **A command-line interpreter is also known as the Kernel.** - **False** (The command-line interpreter is known as the Shell, not the Kernel.) 5. **The CPU-scheduling information in a Process Control Block (PCB) includes process priority and pointers to scheduling queues.** - **True** **Operating System Quiz Answers** 1. **What is the primary role of an Operating System?** - **b) To act as an intermediary between the user and the computer hardware.** 2. **Which of the following is NOT considered an Operating System?** - **d) Microsoft Word** 3. **What component directly interacts with the hardware in an Operating System?** - **c) Kernel** 4. **Which of the following is a function of Process Management in an OS?** - **b) Process creation and deletion** 5. **What does the Main-Memory Management function of an OS manage?** - **c) The allocation and deallocation of memory space** 6. **In the context of an OS, what is a \'file\'?** - **a) A collection of related information defined by its creator.** 7. **Which OS function involves managing a system\'s communication network?** - **c) Networking (Distributed Systems)** 8. **What is the purpose of the Protection System in an OS?** - **b) To manage user authentication and access controls** 9. **What role does the Command-Interpreter System play in an Operating System?** - **b) It interprets and executes user commands.** 10. **Which of the following is an example of a secondary-storage management task?** - **b) Disk scheduling** 11. **Which state is NOT a typical process state in an Operating System?** - **c) Paused** 12. **The Short-term scheduler in an OS is responsible for:** - **b) Selecting processes from the ready queue for CPU execution.** 13. **What is a Context Switch in the context of process management?** - **b) Saving and loading the state of processes during a CPU switch.** 14. **Which of the following describes a \'thread\' in an Operating System?** - **b) A lightweight process sharing resources with other threads.** 15. **What is the main function of the Device Queue?** - **b) To hold processes waiting for a particular I/O device.** 16. **Which scheduling queue contains processes that are ready to execute?** - **c) Ready Queue** 17. **In an Operating System, a \'heap\' is primarily used for:** - **b) Dynamic memory allocation.** 18. **Which type of process is described as spending more time doing I/O than computations?** - **c) I/O-bound process** 19. **The fork system call in UNIX is used to:** - **b) Create a new process.** 20. **A parent process may terminate a child process if:** - **a) The child has exceeded allocated resources.** **Operating System Quiz (Set 2) Answers** 1. **What is the primary function of the Shell in an Operating System?** - **b) Interpret and execute user commands.** 2. **Which of the following is NOT a function of the Kernel?** - **c) User command interpretation** 3. **Which memory type is volatile and loses its content when the system fails?** - **b) Main memory (RAM)** 4. **In which process state is a process waiting for an event, such as I/O completion?** - **c) Blocked (or Waiting)** 5. **Which system call in UNIX is used to replace a process\'s memory space with a new program?** - **b) exec** 6. **What is the primary role of a Long-term Scheduler?** - **b) To manage which jobs are brought into the system for execution.** 7. **Which of the following describes a \'heap\' in memory management?** - **b) A section of memory used for dynamic allocation.** 8. **What does the term \'multiprogramming\' refer to in an OS?** - **a) Executing multiple processes simultaneously.** 9. **Which process scheduling queue is responsible for handling processes that need to wait for a specific I/O device?** - **c) Device Queue** 10. **What is the primary function of the Memory Management Unit (MMU)?** - **b) To translate logical addresses into physical addresses.** 11. **Which of the following best describes the term \'thrashing\' in an Operating System?** - **b) A situation where excessive paging occurs, causing high disk activity.** 12. **Which type of process is created and executed by the system to perform specific tasks like printing or data transfer?** - **b) System process** 13. **In the context of process scheduling, what does the term \'starvation\' refer to?** - **a) A process that never gets CPU time due to scheduling policies.** 14. **Which OS concept involves creating a virtual CPU for each process?** - **c) Time-sharing** 15. **What is the primary function of the I/O buffer in an Operating System?** - **b) To hold data temporarily while it is being transferred between the CPU and an I/O device.** 16. **Which file system operation is responsible for mapping files onto secondary storage?** - **c) File allocation** 17. **What is the role of a Device Driver in an Operating System?** - **b) To translate operating system commands into hardware-specific operations.** 18. **In a Time-Shared Operating System, what is the typical unit of time allocated to each process?** - **c) Time slice** 19. **Which of the following best describes a \'deadlock\' in an Operating System?** - **a) A situation where multiple processes wait indefinitely for resources.** 20. **What is a primary characteristic of a Distributed System?** - **c) Processors connected through a communication network.**

Use Quizgecko on...
Browser
Browser