SlideShare a Scribd company logo
Operating Systems 7.1  Introduction 7.2  Storage Management 7.3  Process Management 7.4  I/O Management
Introduction Os – “Executive Manager”  is the part of the computing system that manages all of the hardware and all of the software. OS controls every device, every section of memory and every nanosecond of processing time. OS also controls who can use the system and how. OS is a program running at all times on a computer with all other programs being application programs.  Without an OS, no applications can be run.  A computer system interfaces the user through an operating system. The user through an operating system enters instructions into a computer system.  Examples : MS-DOS, Windows NT/2000, Mac OS
Major OS Components   Memory Manager  In charge of main memory such as check the validity of each request for memory space etc. Processor Manager Decides how to allocate the CPU. Keep track of status of each process Device Manager Monitors every device, channel and control unit. File Manager Keeps track for every file in the system including data files, assemblers, compilers and application programs. User Command Interface
OS Subsystem Manager Tasks  Monitor its resources continuously Enforce the policies that determine who gets what, when and how much Allocate the resources - reclaim it - when appropriate Deallocate the resource - reclaim it - when appropriate
OS Services Program execution I/O operation File and directory services Communication Error detection and handling Resource allocation Protection Accounting
OS Services i)     Program execution : loads and executes programs, allows      debugging ii)   I/O operation : does all read and write operations which    may involve a file or an I/O device like printer iii)   File system manipulation : allows to read/write files as    well as create and delete them iv)   Communication : allows processes to communicate with    each other v)     Error detection : CPU, hardware, instructions, device  errors vi)    Resource allocation : manages resources so that they are    optimally utilized vii)   Security/protection : stop unauthorized access, protect    system from imposters viii) Accounting : user bills, user/system, statistics
OS functions 1. Provides interface to computer system 2. Control program: controls the various I/O devices and user programs 3. Resource allocator: operating system acts as the manager of these resources and allocates them to specific programs and user. (CPU time, memory space, file storage space and I/O device) OS deals with : 1. storage management 2. memory management  3. process management 4. I/O management
 
Components of OS 1.  Shell Shell is the outer layer of an operating system  is the part of the operating system that interfaces with the user. is the interface to which accepts, interprets and then executes commands from users. 2 types : Command Line Interpreter (CLI) Graphical User Interface (GUI)
Components of OS (cont.) 2.  Kernel the central module of an operating system.  Kernel's position is between application program and device driver. is responsible for resource allocation, low-level hardware interfaces, security  is the part of the operating system that is loaded first, and remains in main memory. Because it stays in memory, it is important for kernel to be as small as possible.
Functions performed by kernel Amongst the functions performed by the kernel are: Managing the machine’s memory and allocating it to each process Scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible Organizing the transfer of data from one part of the machine to another Accepting instructions from the shell and carrying them out Enforcing the access permissions that are in force on the file system
7.2 Primary Storage Management Execution of a program involves a sequence of instructions within that program. The execution of an individual program is called a process or task. Many processes are loaded into RAM. All these processes compete in using the CPU.  A part of kernel, which is called memory manager, manages processes in RAM.
Functions of a memory manager: 1.keeping track of which parts of memory are currently being used and by whom 2.deciding which processes are to be loaded into memory when memory space becomes available 3. allocating and deallocating memory space as needed 4. allowing the running of programs that are larger than memory .
For a program to be executed, it must be mapped to absolute addresses and loaded into memory. As the program executes, it accesses program instructions and data from memory by generating these absolute addresses.  Eventually, when the program terminates, its memory space is declared available, and the next program can be loaded and executed.
7.2 Secondary Memory Management Secondary storage is needed because : I.Main memory is not big enough to keep all data and program 2. Data kept in main memory will be lost if computer is shut down In relation to secondary memory management, OS is concerned about: Free space management  Storage allocation  Disk scheduling
7.2 Virtual Memory Computer can get out of memory when: we run more applications than is allowed by the amount of RAM in the computer  we run a program that requires amount of memory that exceeds the amount of RAM in the computer  to overcome this problem, virtual memory can be used. In virtual memory, part of hard disk is used as an extension to RAM. When a program is executed, part of it is stored on RAM and another part is stored on disk. The part of the program that is stored on disk is only brought into memory when it is executed.   Implementation of virtual memory uses  paging method .
7.2 Virtual Memory Paging method: a program is divided into small segments called page. A page size is normally between 1-4 kB.  This size is constant. An area of hard disk called swap page is specified to hold pages not held in main memory. Main memory is also divided into pages called frame. During program execution, one or more pages are held in memory and the remainder is held in disk or swap space. The pages in disk are copied into main memory when needed for current processing.
7.2 Virtual Memory Paging method: If necessary, existing pages in main memory can be swapped out to disk to make room for pages being swapped in. The selected page that is swapped out is called victim.  Pages that are least recently used or least frequently used are usually victims. When a victim is selected, it might or might not be copied back to the swap space. Each memory reference made by a program must be checked to see it refers to a page in memory. References to pages not contained in memory are referred as page faults. Tables are used to store information about the allocation of program segments to pages and the location of those pages in primary and secondary storage. Each active process will have a table page or portion of a table page dedicated to storing its page information.
7.2 Virtual Memory Advantages of virtual memory: Programs requiring memory space larger than physical memory can be run.  No constraint on the memory size. More programs can be run at one time because one program could take less physical memory. Less I/O would be needed to load or swap each user program into memory, so each user program would run faster. Only pages from disk are swapped instead of programs.  Programming task is easier.  Programmer does not have to worry about memory available.
Swapping Vs Paging Swapping: Moving the entire process which is idle/not running together with all the data from main memory to be used by other processes. Moves the entire address spaces between disk and memory. Paging: Dividing the whole process into pages and the memory into frames. Size of page and frames are the same. When loading a program, any page of the program can be placed in any unused page frame. Moves individual pages only between disk and memory, so part of an address space on disk while the other part is in main memory.
7.3 Process Management A process is a program in execution. Example : saving a Word document, spooling files to printer, a single mathematical calculation A process is active, it contains a program counter that indicates the address in memory of the next instruction to be executed.  A process can be in 5 states: 1. New  2. Running 3. Waiting  :  for some event to occur 4. Ready  :  to be assigned to a processor 5. Terminated  :  finished execution
Only one process can be running at one time. However, many processes may be ready or waiting.  Processes are executed in a sequential manner. The CPU executes one process after another until the process is completed.  Management of processes by the operating system is called  scheduling .   Scheduling is done by   scheduler   (a part of the kernel). Job scheduler: only concerned with selecting jobs from a queue of incoming jobs and placing them in the process queue Process scheduler: assigns the CPU to execute the processes of those jobs placed on the ready queue by the Job Scheduler. In scheduling, a  queue  is created where each process will wait for its execution.  When a process is created, it will be placed at the end of the queue. Process in the front of the queue is taken out and is executed.
A process waiting for a source to use can give in to another process : e.g. waiting for an I/O transfer to finish. Operating system puts the process in a waiting list and does  context switching . In context switching, operating system switches execution from one process to another and comes back to the first process.  Various policies for managing processes : FCFS, SPN, Round Robin.
Job and Process Status Handled by Process Scheduler (low-level scheduler) Handled by Job Scheduler (high-level scheduler) New Ready Running Waiting I/O or event completion Scheduler dispatch I/O or event wait Admitted Interrupt Exit Finished
Transition Among Process States NEW to READY  : Job Scheduler using a  predefined policy. READY to RUNNING  :  Process Scheduler using some predefined algorithm  RUNNING back to READY  :  Process Scheduler according to some predefined time limit or other criterion. RUNNING to WAITING  : Process Scheduler and is initiated by an instruction in the job. WAITING to READY  : Process Scheduler and is initiated by signal from I/O device manager that I/O request has been satisfied and job can continue.  RUNNING to FINISHED  : Process Scheduler or Job Scheduler.
7.3 Time-sharing Occurs when several processes run concurrently on one processor or in parallel on many processors at the same time. A time-sharing operating system uses CPU scheduling and multiprogramming to allow users to share time.  Time-sharing systems are developed to provide interactive use of a computer system at a reasonable cost.  Almost all mainframes and minicomputers are time-sharing systems.
Mechanism of Time-Sharing A time-sharing operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of time-shared computer-> to share time. Several processes are run concurrently -> must be in memory  Needs memory management and protection.  Virtual memory may be used
Advantages of Time-Sharing Allows many users use the computer simultaneously. At any one time, only a little CPU time is given to a user. ->System switches very rapidly from one user to the next : user assumes that he/she owns the computer (actually is shared with other users)
Time Slicing Is a technique where each process is given a slice of time before being preempted.  (each process is given a portion of computer time) When a process is running and the period to run the process has ended, the process will be preempted. Then the next process in the queue will run.  A process will be  preempted  if the period has ended even though it is not finished.  CPU will execute the unfinished process later.
To preempt a process, a  clock interrupt  is generated. The running process will be put into a  ready  queue and the first process in the  ready  queue will be selected. The order of which process to run at one time is determined by the  CPU scheduling algorithms .
A Good Scheduling Policy Maximize throughput  by running as many jobs as possible in a given amount of time.  Maximize CPU efficiency  by keeping CPU busy 100 % of time.  Ensure fairness for all jobs  by giving everyone an equal amount of CPU and I/O time.  Minimize response time  by quickly turning around interactive requests.  Minimize turnaround time  by moving entire jobs in/out of system quickly.  Minimize waiting time  by moving jobs out of READY queue as quickly as possible.
Characterization of Scheduling Policies The  selection function : determines which process in the ready queue is selected next for execution The  decision mode : specifies the instants in time at which the selection function is exercised Non-preemptive Once a process is in the running state, it will continue until it terminates or blocks itself for I/O Preemptive Currently running process may be interrupted and moved to the Ready state by the OS Allows for better service since any one process cannot monopolize the processor for very long
Non-Preemptive Scheduling A process stays on the CPU until it voluntarily releases the CPU Long waiting and response times May lead to starvation Simple, easy to implement Not suited for multi-user systems Euphemism: “cooperative multitasking”
Preemptive Scheduling The execution of a process may be interrupted by the operating system at any time interrupt higher priority process Arrival of a new process, change the status time limit Prevents a process from using the CPU for too long  May lead to race conditions Can be solved by using process synchronization
Scheduling Policies First Come First Served (FCFS) Round Robin (RR) Shortest Process Next (SPN) Shortest Remaining Time (SRT) Highest Response Ratio Next (HRRN)
Example to Discuss Various Scheduling Policies Service time = total processor time needed in one (CPU-I/O) cycle Jobs with long service time are CPU-bound jobs  and are referred to as “long jobs” Process Arrival Time Service Time 1 2 3 4 5 0 2 4 6 8 3 6 4 5 2
First Come First Served (FCFS) Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS) Decision mode:  non-preemptive a process runs until it blocks itself
First Come First Served (FCFS) Non-preemptive. Handles jobs according to their arrival time - the earlier they arrive, the sooner they’re served.  Simple algorithm to implement - uses a FIFO queue.
Disadvantages of FCFS -A process that does not perform any I/O will monopolize the processor -Favors CPU-bound processes I/O-bound processes have to wait until CPU-bound process completes They may have to wait even when their I/O are completed (poor device utilization) We could have kept the I/O devices busy by giving a bit more priority to I/O bound processes
Selection function : same as FCFS Decision mode : preemptive a process is allowed to run until the time slice period (quantum, typically from 10 to 100 ms) has expired then a clock interrupt occurs and the running process is put on the ready queue  Round-Robin
Round Robin Preemptive. Used extensively in interactive systems because it’s easy to implement.  Isn’t based on job characteristics but on a predetermined slice of time that’s given to each job.  Ensures CPU is equally shared among all active processes and isn’t monopolized by any one job. Time slice  is called a  time quantum   size crucial to system performance (100 ms to 1-2 secs)
Round-Robin
Quantum Quantum  is a specific time interval used to prevent any one process monopolizing the system. If the process does not voluntarily release the CPU when the interval/quantum is over, a clock interrupt is generated.
Shortest Process Next (SPN) Selection function: the process with the shortest expected CPU burst time Decision mode: non-preemptive I/O bound processes will be picked first We need to estimate the required processing time (CPU burst time) for each process
Shortest Job Next (SJN) Non-preemptive. Handles jobs based on length of their CPU cycle time.  Use lengths to schedule process with shortest time. Optimal – gives minimum average waiting time for a given set of processes.  optimal only when all of jobs are available at same time and the CPU estimates are available and accurate. Doesn’t work in interactive systems (time-sharing systems) because users don’t estimate in advance CPU time required to run their jobs.
Shortest Remaining Time (SRT) Preemptive -  version of the SJN algorithm.  Processor allocated to job closest to completion. This job can be preempted if a newer job in READY queue has a “time to completion” that's shorter. Can’t be implemented in interactive system - requires advance knowledge of CPU time required to finish each job.  SRT involves more overhead than SJN.  OS monitors CPU time for all jobs in READY queue and performs “context switching”.
7.4 I/O Management I/O Operation and Interrupt Every request from a user program must be done through the OS. When the device is ready to provide service, the device tells the operating system of its status by giving an interrupt. I/O interrupts happen when: an I/O operation completes,  an I/O error occurs, or  a device is made ready.
When an interrupt happens, operating system does the following: The operating system gains control.  The operating system saves the state of the interrupted process.  The operating system analyzes the interrupt and passes the control to the appropriate routine to handle interrupt.  The interrupt handler routine processes the interrupt.  The state of the interrupted process is restored.  The interrupted process executes.
Spooling Spooling uses buffer to manage files to be printed. Files which are spooled are queued and copied to printer one at a time. To manage I/O requests, operating system has a component that is called  spooler .  Spooler manages I/O requests to a printer. Spooler operates in the background and creates a printing schedule.
Importance of Spooling 1. In spooling, programs can run to completion faster. Therefore, other programs can start sooner. Spooling improves the system by disassociating a program from the slow operating speed of devices such as printers.  2. Since files are stored in a buffer, where the printer can access them; we can perform other operations on the computer while the printing takes place. Therefore, computation of one job can overlap with the I/O of other jobs. Thus, spooling can keep both the CPU and the I/O devices working at much higher performance rates. 3. Spooling lets us put a number of print jobs in queue instead of waiting for each one to finish before specifying the next one. If we need to remove unwanted jobs before the jobs print, we are able to do so. We can also suspend a printing job if the printing job is still on queue.
Discussion What are main services provided by an operating system? What are some advantages of paging? Distinguish swapping and paging. What potential CPU-allocation problems exist if a purely round-robin (no-priority) system is used to select the next job from the ready queue? What is the main difference of a time-sharing system and how is it usually implemented?
Discussion Five jobs are in the READY queue waiting to be processed. Their estimated CPU cycles are as follows: 10, 3, 6, 6 and 2. Using SJN, in what order should they be processed to minimize average waiting time?
Discussion Given the following information: Draw a time line for each of the following scheduling algorithms: FCFS SJN SRT Round-Robin (using a time quantum of 2)

More Related Content

PDF
Mathematical modeling
PPTX
Operating system and its function
PPTX
Olsr protocol ppt
PPTX
Graph in data structure
PDF
Impact of cinema on youth dessertation final cut
PPTX
PPT
Social Media & SEO Proposal
PDF
NPTEL BIG DATA FULL PPT BOOK WITH ASSIGNMENT SOLUTION RAJIV MISHRA IIT PATNA...
Mathematical modeling
Operating system and its function
Olsr protocol ppt
Graph in data structure
Impact of cinema on youth dessertation final cut
Social Media & SEO Proposal
NPTEL BIG DATA FULL PPT BOOK WITH ASSIGNMENT SOLUTION RAJIV MISHRA IIT PATNA...

What's hot (20)

PPTX
Presentation on Operating System & its Components
PPTX
Operating system overview concepts ppt
PDF
Introduction to Operating Systems
PPTX
Operating system
PPTX
Operating systems
PPTX
Os ppt
PPTX
PPT
Operating systems for class 9th class
PPTX
Fundamentals of operating system
PPTX
Operating system
PPT
Presentation on operating system
PPTX
Central Processing Unit
PPT
Operating system.ppt (1)
PDF
Operating system concepts (notes)
PPTX
Operating System- Services,types.Batch files and DOS history
PPTX
Computer Fundamental
PDF
Graphical programming
PPTX
Computing Environment
PPTX
Batch operating system
PPTX
Input devices presentation
Presentation on Operating System & its Components
Operating system overview concepts ppt
Introduction to Operating Systems
Operating system
Operating systems
Os ppt
Operating systems for class 9th class
Fundamentals of operating system
Operating system
Presentation on operating system
Central Processing Unit
Operating system.ppt (1)
Operating system concepts (notes)
Operating System- Services,types.Batch files and DOS history
Computer Fundamental
Graphical programming
Computing Environment
Batch operating system
Input devices presentation
Ad

Viewers also liked (20)

PPTX
Operating Systems
PPTX
Operating systems Overview
PPTX
Types of operating system
PPTX
INTRODUCTION TO OPERATING SYSTEM
PPTX
Roll of os
PPT
Linux concept workshop
PPTX
Virtual memory (testing)
PPTX
Introduction to Operating System
PDF
Lecture 3 basic syntax and semantics
PPTX
Operating system
PPTX
Operating system kernal
PPT
Real time operating system
PPT
System call
PPT
Operating System
PPTX
Operating system introducton and tyes
PPTX
What is Kernel, basic idea of kernel
PPT
Introduction to operating syatem
PPTX
Kernel (computing)
PPTX
System calls
PPTX
Operating system introduction to operating system
Operating Systems
Operating systems Overview
Types of operating system
INTRODUCTION TO OPERATING SYSTEM
Roll of os
Linux concept workshop
Virtual memory (testing)
Introduction to Operating System
Lecture 3 basic syntax and semantics
Operating system
Operating system kernal
Real time operating system
System call
Operating System
Operating system introducton and tyes
What is Kernel, basic idea of kernel
Introduction to operating syatem
Kernel (computing)
System calls
Operating system introduction to operating system
Ad

Similar to introduction To Operating System (20)

PPT
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
PPT
PPTX
PDF
Software concepts
PPT
Basics of Operating System
PDF
R20CSE2202-OPERATING-SYSTEMS .pdf
PPTX
Difference Program vs Process vs Thread
PPTX
UNIT 1FUNDAMENTALS OF OPERATING SYSTEMS.pptx
DOCX
Operating system
PPTX
os assignment -individual presenation.pptx
PPTX
PROJECT 3.pptx
PDF
Operating system notes pdf
PPTX
installing and optimizing operating system software
PDF
Operating System Lecture Notes
PDF
Introduction of OS & Classification of Software
PPTX
INSTAL AND OPTIMIZE OPERATING SYSTEM WINDOWS
PPTX
Operating System Introduction.pptx
PPT
Introduction of operating system
PPTX
2 opreating system
PPTX
Chapter 2 operating systems
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
Software concepts
Basics of Operating System
R20CSE2202-OPERATING-SYSTEMS .pdf
Difference Program vs Process vs Thread
UNIT 1FUNDAMENTALS OF OPERATING SYSTEMS.pptx
Operating system
os assignment -individual presenation.pptx
PROJECT 3.pptx
Operating system notes pdf
installing and optimizing operating system software
Operating System Lecture Notes
Introduction of OS & Classification of Software
INSTAL AND OPTIMIZE OPERATING SYSTEM WINDOWS
Operating System Introduction.pptx
Introduction of operating system
2 opreating system
Chapter 2 operating systems

Recently uploaded (20)

PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Mushroom cultivation and it's methods.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
A Presentation on Touch Screen Technology
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Web App vs Mobile App What Should You Build First.pdf
Hindi spoken digit analysis for native and non-native speakers
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Programs and apps: productivity, graphics, security and other tools
Univ-Connecticut-ChatGPT-Presentaion.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Assigned Numbers - 2025 - Bluetooth® Document
WOOl fibre morphology and structure.pdf for textiles
Digital-Transformation-Roadmap-for-Companies.pptx
TLE Review Electricity (Electricity).pptx
Mushroom cultivation and it's methods.pdf
Encapsulation theory and applications.pdf
cloud_computing_Infrastucture_as_cloud_p
A Presentation on Touch Screen Technology
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A comparative analysis of optical character recognition models for extracting...
Web App vs Mobile App What Should You Build First.pdf

introduction To Operating System

  • 1. Operating Systems 7.1 Introduction 7.2 Storage Management 7.3 Process Management 7.4 I/O Management
  • 2. Introduction Os – “Executive Manager” is the part of the computing system that manages all of the hardware and all of the software. OS controls every device, every section of memory and every nanosecond of processing time. OS also controls who can use the system and how. OS is a program running at all times on a computer with all other programs being application programs. Without an OS, no applications can be run. A computer system interfaces the user through an operating system. The user through an operating system enters instructions into a computer system. Examples : MS-DOS, Windows NT/2000, Mac OS
  • 3. Major OS Components Memory Manager In charge of main memory such as check the validity of each request for memory space etc. Processor Manager Decides how to allocate the CPU. Keep track of status of each process Device Manager Monitors every device, channel and control unit. File Manager Keeps track for every file in the system including data files, assemblers, compilers and application programs. User Command Interface
  • 4. OS Subsystem Manager Tasks Monitor its resources continuously Enforce the policies that determine who gets what, when and how much Allocate the resources - reclaim it - when appropriate Deallocate the resource - reclaim it - when appropriate
  • 5. OS Services Program execution I/O operation File and directory services Communication Error detection and handling Resource allocation Protection Accounting
  • 6. OS Services i)     Program execution : loads and executes programs, allows debugging ii) I/O operation : does all read and write operations which may involve a file or an I/O device like printer iii)   File system manipulation : allows to read/write files as well as create and delete them iv)   Communication : allows processes to communicate with each other v)    Error detection : CPU, hardware, instructions, device errors vi)    Resource allocation : manages resources so that they are optimally utilized vii) Security/protection : stop unauthorized access, protect system from imposters viii) Accounting : user bills, user/system, statistics
  • 7. OS functions 1. Provides interface to computer system 2. Control program: controls the various I/O devices and user programs 3. Resource allocator: operating system acts as the manager of these resources and allocates them to specific programs and user. (CPU time, memory space, file storage space and I/O device) OS deals with : 1. storage management 2. memory management 3. process management 4. I/O management
  • 8.  
  • 9. Components of OS 1. Shell Shell is the outer layer of an operating system is the part of the operating system that interfaces with the user. is the interface to which accepts, interprets and then executes commands from users. 2 types : Command Line Interpreter (CLI) Graphical User Interface (GUI)
  • 10. Components of OS (cont.) 2. Kernel the central module of an operating system. Kernel's position is between application program and device driver. is responsible for resource allocation, low-level hardware interfaces, security is the part of the operating system that is loaded first, and remains in main memory. Because it stays in memory, it is important for kernel to be as small as possible.
  • 11. Functions performed by kernel Amongst the functions performed by the kernel are: Managing the machine’s memory and allocating it to each process Scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible Organizing the transfer of data from one part of the machine to another Accepting instructions from the shell and carrying them out Enforcing the access permissions that are in force on the file system
  • 12. 7.2 Primary Storage Management Execution of a program involves a sequence of instructions within that program. The execution of an individual program is called a process or task. Many processes are loaded into RAM. All these processes compete in using the CPU. A part of kernel, which is called memory manager, manages processes in RAM.
  • 13. Functions of a memory manager: 1.keeping track of which parts of memory are currently being used and by whom 2.deciding which processes are to be loaded into memory when memory space becomes available 3. allocating and deallocating memory space as needed 4. allowing the running of programs that are larger than memory .
  • 14. For a program to be executed, it must be mapped to absolute addresses and loaded into memory. As the program executes, it accesses program instructions and data from memory by generating these absolute addresses. Eventually, when the program terminates, its memory space is declared available, and the next program can be loaded and executed.
  • 15. 7.2 Secondary Memory Management Secondary storage is needed because : I.Main memory is not big enough to keep all data and program 2. Data kept in main memory will be lost if computer is shut down In relation to secondary memory management, OS is concerned about: Free space management Storage allocation Disk scheduling
  • 16. 7.2 Virtual Memory Computer can get out of memory when: we run more applications than is allowed by the amount of RAM in the computer we run a program that requires amount of memory that exceeds the amount of RAM in the computer to overcome this problem, virtual memory can be used. In virtual memory, part of hard disk is used as an extension to RAM. When a program is executed, part of it is stored on RAM and another part is stored on disk. The part of the program that is stored on disk is only brought into memory when it is executed. Implementation of virtual memory uses paging method .
  • 17. 7.2 Virtual Memory Paging method: a program is divided into small segments called page. A page size is normally between 1-4 kB. This size is constant. An area of hard disk called swap page is specified to hold pages not held in main memory. Main memory is also divided into pages called frame. During program execution, one or more pages are held in memory and the remainder is held in disk or swap space. The pages in disk are copied into main memory when needed for current processing.
  • 18. 7.2 Virtual Memory Paging method: If necessary, existing pages in main memory can be swapped out to disk to make room for pages being swapped in. The selected page that is swapped out is called victim. Pages that are least recently used or least frequently used are usually victims. When a victim is selected, it might or might not be copied back to the swap space. Each memory reference made by a program must be checked to see it refers to a page in memory. References to pages not contained in memory are referred as page faults. Tables are used to store information about the allocation of program segments to pages and the location of those pages in primary and secondary storage. Each active process will have a table page or portion of a table page dedicated to storing its page information.
  • 19. 7.2 Virtual Memory Advantages of virtual memory: Programs requiring memory space larger than physical memory can be run. No constraint on the memory size. More programs can be run at one time because one program could take less physical memory. Less I/O would be needed to load or swap each user program into memory, so each user program would run faster. Only pages from disk are swapped instead of programs. Programming task is easier. Programmer does not have to worry about memory available.
  • 20. Swapping Vs Paging Swapping: Moving the entire process which is idle/not running together with all the data from main memory to be used by other processes. Moves the entire address spaces between disk and memory. Paging: Dividing the whole process into pages and the memory into frames. Size of page and frames are the same. When loading a program, any page of the program can be placed in any unused page frame. Moves individual pages only between disk and memory, so part of an address space on disk while the other part is in main memory.
  • 21. 7.3 Process Management A process is a program in execution. Example : saving a Word document, spooling files to printer, a single mathematical calculation A process is active, it contains a program counter that indicates the address in memory of the next instruction to be executed. A process can be in 5 states: 1. New 2. Running 3. Waiting : for some event to occur 4. Ready : to be assigned to a processor 5. Terminated : finished execution
  • 22. Only one process can be running at one time. However, many processes may be ready or waiting. Processes are executed in a sequential manner. The CPU executes one process after another until the process is completed. Management of processes by the operating system is called scheduling . Scheduling is done by scheduler (a part of the kernel). Job scheduler: only concerned with selecting jobs from a queue of incoming jobs and placing them in the process queue Process scheduler: assigns the CPU to execute the processes of those jobs placed on the ready queue by the Job Scheduler. In scheduling, a queue is created where each process will wait for its execution. When a process is created, it will be placed at the end of the queue. Process in the front of the queue is taken out and is executed.
  • 23. A process waiting for a source to use can give in to another process : e.g. waiting for an I/O transfer to finish. Operating system puts the process in a waiting list and does context switching . In context switching, operating system switches execution from one process to another and comes back to the first process. Various policies for managing processes : FCFS, SPN, Round Robin.
  • 24. Job and Process Status Handled by Process Scheduler (low-level scheduler) Handled by Job Scheduler (high-level scheduler) New Ready Running Waiting I/O or event completion Scheduler dispatch I/O or event wait Admitted Interrupt Exit Finished
  • 25. Transition Among Process States NEW to READY : Job Scheduler using a predefined policy. READY to RUNNING : Process Scheduler using some predefined algorithm RUNNING back to READY : Process Scheduler according to some predefined time limit or other criterion. RUNNING to WAITING : Process Scheduler and is initiated by an instruction in the job. WAITING to READY : Process Scheduler and is initiated by signal from I/O device manager that I/O request has been satisfied and job can continue. RUNNING to FINISHED : Process Scheduler or Job Scheduler.
  • 26. 7.3 Time-sharing Occurs when several processes run concurrently on one processor or in parallel on many processors at the same time. A time-sharing operating system uses CPU scheduling and multiprogramming to allow users to share time. Time-sharing systems are developed to provide interactive use of a computer system at a reasonable cost. Almost all mainframes and minicomputers are time-sharing systems.
  • 27. Mechanism of Time-Sharing A time-sharing operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of time-shared computer-> to share time. Several processes are run concurrently -> must be in memory Needs memory management and protection. Virtual memory may be used
  • 28. Advantages of Time-Sharing Allows many users use the computer simultaneously. At any one time, only a little CPU time is given to a user. ->System switches very rapidly from one user to the next : user assumes that he/she owns the computer (actually is shared with other users)
  • 29. Time Slicing Is a technique where each process is given a slice of time before being preempted. (each process is given a portion of computer time) When a process is running and the period to run the process has ended, the process will be preempted. Then the next process in the queue will run. A process will be preempted if the period has ended even though it is not finished. CPU will execute the unfinished process later.
  • 30. To preempt a process, a clock interrupt is generated. The running process will be put into a ready queue and the first process in the ready queue will be selected. The order of which process to run at one time is determined by the CPU scheduling algorithms .
  • 31. A Good Scheduling Policy Maximize throughput by running as many jobs as possible in a given amount of time. Maximize CPU efficiency by keeping CPU busy 100 % of time. Ensure fairness for all jobs by giving everyone an equal amount of CPU and I/O time. Minimize response time by quickly turning around interactive requests. Minimize turnaround time by moving entire jobs in/out of system quickly. Minimize waiting time by moving jobs out of READY queue as quickly as possible.
  • 32. Characterization of Scheduling Policies The selection function : determines which process in the ready queue is selected next for execution The decision mode : specifies the instants in time at which the selection function is exercised Non-preemptive Once a process is in the running state, it will continue until it terminates or blocks itself for I/O Preemptive Currently running process may be interrupted and moved to the Ready state by the OS Allows for better service since any one process cannot monopolize the processor for very long
  • 33. Non-Preemptive Scheduling A process stays on the CPU until it voluntarily releases the CPU Long waiting and response times May lead to starvation Simple, easy to implement Not suited for multi-user systems Euphemism: “cooperative multitasking”
  • 34. Preemptive Scheduling The execution of a process may be interrupted by the operating system at any time interrupt higher priority process Arrival of a new process, change the status time limit Prevents a process from using the CPU for too long May lead to race conditions Can be solved by using process synchronization
  • 35. Scheduling Policies First Come First Served (FCFS) Round Robin (RR) Shortest Process Next (SPN) Shortest Remaining Time (SRT) Highest Response Ratio Next (HRRN)
  • 36. Example to Discuss Various Scheduling Policies Service time = total processor time needed in one (CPU-I/O) cycle Jobs with long service time are CPU-bound jobs and are referred to as “long jobs” Process Arrival Time Service Time 1 2 3 4 5 0 2 4 6 8 3 6 4 5 2
  • 37. First Come First Served (FCFS) Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS) Decision mode: non-preemptive a process runs until it blocks itself
  • 38. First Come First Served (FCFS) Non-preemptive. Handles jobs according to their arrival time - the earlier they arrive, the sooner they’re served. Simple algorithm to implement - uses a FIFO queue.
  • 39. Disadvantages of FCFS -A process that does not perform any I/O will monopolize the processor -Favors CPU-bound processes I/O-bound processes have to wait until CPU-bound process completes They may have to wait even when their I/O are completed (poor device utilization) We could have kept the I/O devices busy by giving a bit more priority to I/O bound processes
  • 40. Selection function : same as FCFS Decision mode : preemptive a process is allowed to run until the time slice period (quantum, typically from 10 to 100 ms) has expired then a clock interrupt occurs and the running process is put on the ready queue Round-Robin
  • 41. Round Robin Preemptive. Used extensively in interactive systems because it’s easy to implement. Isn’t based on job characteristics but on a predetermined slice of time that’s given to each job. Ensures CPU is equally shared among all active processes and isn’t monopolized by any one job. Time slice is called a time quantum size crucial to system performance (100 ms to 1-2 secs)
  • 43. Quantum Quantum is a specific time interval used to prevent any one process monopolizing the system. If the process does not voluntarily release the CPU when the interval/quantum is over, a clock interrupt is generated.
  • 44. Shortest Process Next (SPN) Selection function: the process with the shortest expected CPU burst time Decision mode: non-preemptive I/O bound processes will be picked first We need to estimate the required processing time (CPU burst time) for each process
  • 45. Shortest Job Next (SJN) Non-preemptive. Handles jobs based on length of their CPU cycle time. Use lengths to schedule process with shortest time. Optimal – gives minimum average waiting time for a given set of processes. optimal only when all of jobs are available at same time and the CPU estimates are available and accurate. Doesn’t work in interactive systems (time-sharing systems) because users don’t estimate in advance CPU time required to run their jobs.
  • 46. Shortest Remaining Time (SRT) Preemptive - version of the SJN algorithm. Processor allocated to job closest to completion. This job can be preempted if a newer job in READY queue has a “time to completion” that's shorter. Can’t be implemented in interactive system - requires advance knowledge of CPU time required to finish each job. SRT involves more overhead than SJN. OS monitors CPU time for all jobs in READY queue and performs “context switching”.
  • 47. 7.4 I/O Management I/O Operation and Interrupt Every request from a user program must be done through the OS. When the device is ready to provide service, the device tells the operating system of its status by giving an interrupt. I/O interrupts happen when: an I/O operation completes, an I/O error occurs, or a device is made ready.
  • 48. When an interrupt happens, operating system does the following: The operating system gains control. The operating system saves the state of the interrupted process. The operating system analyzes the interrupt and passes the control to the appropriate routine to handle interrupt. The interrupt handler routine processes the interrupt. The state of the interrupted process is restored. The interrupted process executes.
  • 49. Spooling Spooling uses buffer to manage files to be printed. Files which are spooled are queued and copied to printer one at a time. To manage I/O requests, operating system has a component that is called spooler . Spooler manages I/O requests to a printer. Spooler operates in the background and creates a printing schedule.
  • 50. Importance of Spooling 1. In spooling, programs can run to completion faster. Therefore, other programs can start sooner. Spooling improves the system by disassociating a program from the slow operating speed of devices such as printers. 2. Since files are stored in a buffer, where the printer can access them; we can perform other operations on the computer while the printing takes place. Therefore, computation of one job can overlap with the I/O of other jobs. Thus, spooling can keep both the CPU and the I/O devices working at much higher performance rates. 3. Spooling lets us put a number of print jobs in queue instead of waiting for each one to finish before specifying the next one. If we need to remove unwanted jobs before the jobs print, we are able to do so. We can also suspend a printing job if the printing job is still on queue.
  • 51. Discussion What are main services provided by an operating system? What are some advantages of paging? Distinguish swapping and paging. What potential CPU-allocation problems exist if a purely round-robin (no-priority) system is used to select the next job from the ready queue? What is the main difference of a time-sharing system and how is it usually implemented?
  • 52. Discussion Five jobs are in the READY queue waiting to be processed. Their estimated CPU cycles are as follows: 10, 3, 6, 6 and 2. Using SJN, in what order should they be processed to minimize average waiting time?
  • 53. Discussion Given the following information: Draw a time line for each of the following scheduling algorithms: FCFS SJN SRT Round-Robin (using a time quantum of 2)