650 likes | 766 Views
Chapter 7. Operating Systems. O BJECTIVES. Understand the components of an operating system. Understand the concept of virtual memory. Understand the concept of deadlock and starvation. List some of the characteristics of popular operating systems such as Windows 2000, UNIX, and Linux.
E N D
Chapter 7 Operating Systems
OBJECTIVES Understand the components of an operating system. Understand the concept of virtual memory. Understand the concept of deadlock and starvation. List some of the characteristics of popular operating systemssuch as Windows 2000, UNIX, and Linux. Define the purpose and functions of an operating system. After reading this chapter, the reader should be able to:
Figure 7-1 Computer System Control the access of hardware by users Used computers Hardware to solve users’ problems.
7.1 DEFINITION
Operating System A program (set of program) that facilitates the execution of OTHER programs As an INTERFACE between H/W of computer and the user (program/humans) Act as general manager supervising activities of component in computer system
Note: An operating system is an interface between the hardware of a computer and the user (program or human) that facilitates the execution of the other programs and the access to hardware and software resources.
Goals of OS Efficient use of hardware Easy to use resources
7.2 EVOLUTION
OS evolution Batch Systems Designed in 1950 • control mainframes computers • Input = punched cards Program to be executed = JOB • Output = line printer OS only ensured that all resources transferred form one job to the next • Secondary storage = tape devices
JOB EXECUTION IN BATCH SYSTEM OPERATOR PROGRAMMER Sent a request to OPERATING ROOM JOB Process PUNCH CARD – contains program and data SUCCESS? Result ERROR- printout
Programmable: punch cardsJoseph Jacquard (1752-1834): punch card loom punch card tabulator
TIME SHARING SYSTEMS Use resources efficiently Multiprogramming Time sharing = resources can be shared between different jobs Allocate resources to different program Hold several jobs in memory scheduling Decide which program should use which resource when Only assign a resources to a job that need it resources availability
INTERACT DIRECLTY user system PROGRAM JOB PROCESS PROGRAM TO BE RUN PROGRAM IN MEMORY AND WAITING FOR RESOURCES
PERSONAL SYSTEMS Single-User Operating Systems DOS= Disk Operating System
PARALLEL SYSTEMS Complex OS More SPEED and efficiency Serve 1 program/part of program MULTIPLE CPUs on same Machine Many tasks can be accomplished in parallel instead of serially
DISTRIBUTED SYSTEMS Networking Internetworking JOB PROGRAM previous now Internet Done all on 1 PC Can be shared between computers (miles apart) RUN partially in one/another pc Need file located everywhere Resources can be distributed
7.3 COMPONENTS
Essential managers of an operating system: Memory Manager Processor Manager Device Manager File Manager Each manager both works closely with the other managers and performs its unique role User Command Interface is unique to each operating system responsible for communication outside the OS Operating System Software
Operating System Software (continued) Figure 1.1: Model of a non-networkedoperatingsystem
Figure 7-2 Components of an operating system
Each subsystem managermust perform the following tasks: Monitor its resources continuously Enforce the policies that determine who gets what, when, and how much Allocate the resource when it’s appropriate Deallocate the resource when appropriate Operating System Software (continued)
Operating System Software (continued) Figure 1.2: Subsystems managers at the base of a pyramid
MEMORY MANAGER MEMORY Management MEMORY allocation = prevent “running out of memory” syndrome Monoprogramming MEMORY Management Multiprogramming
Figure 7-3 Monoprogramming Belongs to the past, its help you to understand multiprogramming Memory capacity dedicated to ONE single program; only small part needed to hold the OS Whole program is in MEMORY for execution When program finished; replaced by another program
MEMORY MANAGER Load program into memory Runs it Replace with next program PROBLEMS Program must fit memory or CANNOT run No other program can be executed I/O devices slow compared to CPU Inefficient use of memory and CPU If there are I/O operation = CPU idle
Memory Manager: In charge of main memory (RAM) Responsibilities include: Preserves the space in main memory occupied by the operating system Checks the validity of each request for memory space Sets up a table to keep track of who is using which section of memory in a multiuser environment Deallocates memory when the time comes to reclaim the memory Operating System Software (continued)
Figure 7-4 Multiprogramming More than one program in memory at the same time Executed concurrently CPU switches between programs During execution; program can be swapped between memory and disk one or more times.
Figure 7-5 Categories of multiprogramming
Technique used in multiprogramming Memory divided into variable length sections Each sections or program holds one program The CPU switches between program Partitioning
Figure 7-6 Partitioning execution start CPU save address of memory location CPU moves back to 1st program
Issues in Partitioning If size large = might some holes Size of partition determined beforehand by the Memory Mgr If size small = prog cannot loaded into RAM If even perfect= may be some holes after program replaced by other When many holes = MM compact the partition to removes hole But this create overhead on the system
Paging PAGE FRAMES Improves efficiency of partitioning same and equal to block size used by system to retrieve I from storage devices MEMORY divided EQUALLY size section called FRAMES PROGRAM MEMORY PROGRAM divided EQUALLY size section called PAGES FRAME PAGE PAGE PAGE PAGE
Figure 7-7 Paging PROGRAM not contiguous in MEMORY location Adv: NO need for new program to wait until six contiguous frames are free Whole program still needs to be in memory b4 executed
Demand Paging Program divided into pages Pages load into memory 1 by 1; executed and replaces by another page Memory hold one program from multiple program at same time Consecutive pages from same program do not have to be load into same frame Page can be load into any free frame
Demand Segmentation Program divided into segments that match the programmers’ vies Pages load into; executed and replaced by another module from same or different program
Demand Paging and Segmentation Combined to further improved efficiency of the system Memory divide into frames, a module divides into pages The pages module can the be load into memory one by one and executed
Disadvantages of early schemes: Required storing entire program inmemory Fragmentation Overhead due to relocation Evolution of virtual memory helps to: Remove the restriction of storing programs contiguously Eliminate the need for entire program to reside in memoryduring execution Memory Management:Virtual Memory
Figure 7-8 Virtual memory VM= implies demand paging, demand segmentation, or both
State diagram with the boundaries between a program, a job, and a process Figure 7-9 Written by a programmer; store on disk Become a job from the moment it is selected for execution Every JOB is a PROGRAM, but not every PROGRAM is a JOB Program in execution; has started but not finished; a job residing in RAM Every PROCESS is a JOB, but not every JOB is a process
Figure 7-10 Job scheduler Moves a job from the hold state to ready state ; or form running to terminated state Responsible for creating a process from job and terminating process
Figure 7-11 Process scheduler Moves a process from one state to another; running state to waiting state When CPU ready to run the process, PS move the process from ready state to running state
Figure 7-12 Queues for process management Waiting lists: associated with each job or process is a Job Control Block (JCB) or Process Control Block(PCB) that stores information about that job or process Hold process that are in memory; ready to run; waiting for CPU Hold jobs waiting for memory Hold process waiting for I/O device
Figure 7-13 Deadlock
Figure 7-14 Deadlock on a bridge
Condition For Deadlocks Mutual exclusion : only 1 process can hold a resources Resource holding : a process hold a resource even though it cannot use until other resources are available No-preemption: the OS cannot temporarily reallocate a resources Circular waiting: all process and resources involved form a loop
Note: Deadlock occurs when the operatingsystem does not put resource restrictionson processes.
Figure 7-15.a Starvation
Figure 7-15.b Starvation
Figure 7-15.c Starvation
Figure 7-16 Dining philosophers