Operating Systems PDF
Document Details
Uploaded by InstructiveEnlightenment615
Air University
Abu Bakar Siddique
Tags
Related
Summary
These notes cover the topics of operating systems, including their function in computer systems. They delve into various concepts such as scheduling and management, touching on different approaches like FCFS, SJF, and Round Robin.
Full Transcript
Application of Communication and Information Technologies Fall 2024 Course Instructor: Mr. Abu Bakar Siddique - Lecturer Department of Creative Technologies Air University - Islamabad [email protected] About Instructor Mr. Abu B...
Application of Communication and Information Technologies Fall 2024 Course Instructor: Mr. Abu Bakar Siddique - Lecturer Department of Creative Technologies Air University - Islamabad [email protected] About Instructor Mr. Abu Bakar Siddique MS Computer Engineering GIK Institute BS Computer Software Engineering UET Peshawar Topics Covered Operating system What Operating System Do? Functions of Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. OR: An operating system (OS) is software that acts as an interface between the hardware and the user. It manages hardware and software resources of a computer. Provides a platform for application program to run. ▪ Example: Windows, Linux, macOS, Android, iOS. 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. Simplifies user interaction with hardware. Allow multiple applications to run simultaneously. Computer System Structure ▪ Computer system can be divided into four components: Hardware – provides basic computing resources CPU, memory, I/O devices Operating system Controls and coordinates use of hardware among various applications and users Application programs – define the ways in which the system resources are used to solve the computing problems of the users Word processors, compilers, web browsers, database systems, video games Users People, machines, other computers Abstract View of Components of Computer Four Components of a Computer System What Operating Systems Do ▪ Depends on the point of view. ▪ Users want convenience, ease of use and good performance Don’t care about resource utilization ▪ But shared computer such as mainframe or minicomputer must keep all users happy. Operating system is a resource allocator and control program making efficient use of HW and managing execution of user programs. ▪ Users of dedicate systems such as workstations have dedicated resources but frequently use shared resources from servers. What Operating System Do ▪ Mobile devices like smartphones and tables are resource poor, optimized for usability and battery life. Mobile user interfaces such as touch screens, voice recognition ▪ Some computers have little or no user interface, such as embedded computers in devices and automobiles Run primarily without user intervention Functions of an Operating System Process management - Handles creation, scheduling, and termination of processes. Memory Management - Allocates and deallocates memory for processes. File System Management - Organizes and manages files on storage devices. Device Management - Controls input/output devices. Security and Access Control – Ensures data safety and system security. Types of Operating System Batch Operating System: Executes tasks in batches without user interaction. Example: Early IBM systems. Time-Sharing Operating System: Allow multiple users to use the system simultaneously. Example: UNIX Real-time Operating System: Processes tasks with strict time limit. Example: Air traffic control system Components of Operating System Kernel: The core component managing hardware and resources. Shell: Interface for users to interact with the OS (CLI or GUI). File system: Organizes data and files on storage devices. Device Drivers: Software that controls hardware devices. System Libraries: Helps in system calls and functionalities. Process Management Basics What is Process? A process is program in execution. Process state: New, Ready, Running, Waiting, Terminated. CPU Scheduler ▪ The CPU scheduler selects from among the processes in ready queue, and allocates a CPU core to one of them Queue may be ordered in various ways ▪ CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates ▪ For situations 1 and 4, there is no choice in terms of scheduling. A new process (if one exists in the ready queue) must be selected for execution. ▪ For situations 2 and 3, however, there is a choice. Preemptive and Nonpreemptive Scheduling ▪ When scheduling takes place only under circumstances 1 and 4, the scheduling scheme is nonpreemptive. ▪ Otherwise, it is preemptive. ▪ Under Nonpreemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases it either by terminating or by switching to the waiting state. ▪ Virtually all modern operating systems including Windows, MacOS, Linux, and UNIX use preemptive scheduling algorithms. Preemptive Scheduling and Race Conditions ▪ Preemptive scheduling can result in race conditions when data are shared among several processes. ▪ Consider the case of two processes that share data. While one process is updating the data, it is preempted so that the second process can run. The second process then tries to read the data, which are in an inconsistent state. 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. Scheduling Algorithm Optimization Criteria ▪ Max CPU utilization ▪ Max throughput ▪ Min turnaround time ▪ Min waiting time ▪ Min response time First- Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 3 P3 3 ▪ Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: ▪ Waiting time for P1 = 0; P2 = 24; P3 = 27 ▪ Average waiting time: (0 + 24 + 27)/3 = 17 FCFS Scheduling (Cont.) Suppose that the processes arrive in the order: P2 , P3 , P1 ▪ The Gantt chart for the schedule is: ▪ Waiting time for P1 = 6; P2 = 0; P3 = 3 ▪ Average waiting time: (6 + 0 + 3)/3 = 3 ▪ Much better than previous case. ▪ Convoy effect - short process behind long process Consider one CPU-bound and many I/O-bound processes Shortest-Job-First (SJF) Scheduling ▪ Associate with each process the length of its next CPU burst Use these lengths to schedule the process with the shortest time ▪ SJF is optimal – gives minimum average waiting time for a given set of processes The difficulty is knowing the length of the next CPU request Could ask the user Shortest-Job-First (SJF) Scheduling ▪ Associate with each process the length of its next CPU burst Use these lengths to schedule the process with the shortest time ▪ SJF is optimal – gives minimum average waiting time for a given set of processes ▪ Preemptive version called shortest-remaining-time-first ▪ How do we determine the length of the next CPU burst? Could ask the user Estimate Example of SJF Processriva l Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 ▪ SJF scheduling chart ▪ Average waiting time = (3 + 16 + 9 + 0) / 4 = 7 Round Robin (RR) ▪ Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. ▪ If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. ▪ Timer interrupts every quantum to schedule next process ▪ Performance q large ⇒ FIFO q small ⇒ q must be large with respect to context switch, otherwise overhead is too high Example of RR with Time Quantum= 4 Process Burst Time P1 24 P2 3 P3 3 ▪ The Gantt chart is: ▪ Typically, higher average turnaround than SJF, but better response. ▪ q should be large compared to context switch time q usually 10 milliseconds to 100 milliseconds, Time Quantum and Context Switch Time Memory Management Basics Memory management involves managing computer memory efficiently. Allocate memory to processes. Free memory when no longer needed. Types of Memory: Primary Memory (RAM), Secondary (Hard Disk). Virtual Memory: Allows running larger programs than physical memory. Files System Basics A file system organizes and stores data. Functions: File creation and deletion. Directory management. File access control. Example: Files in Windows (C:), Files in linux (/home) Input/Output (I/O) Management Manages I/O devices like keyboards, printers, and hard disks. Device Drivers: Interface software for hardware. Buffering and Caching: Temporary data storage for performance improvement. Example: Printing a document involves buffering in memory. Thank you!