Presentation is loading. Please wait.

Presentation is loading. Please wait.

©Brooks/Cole, 2003 Chapter 7 Operating Systems. ©Brooks/Cole, 2003 Define the purpose and functions of an operating system. Understand the components.

Similar presentations


Presentation on theme: "©Brooks/Cole, 2003 Chapter 7 Operating Systems. ©Brooks/Cole, 2003 Define the purpose and functions of an operating system. Understand the components."— Presentation transcript:

1 ©Brooks/Cole, 2003 Chapter 7 Operating Systems

2 ©Brooks/Cole, 2003 Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the concept of virtual memory. Understand the concept of deadlock and starvation. After reading this chapter, the reader should be able to: O BJECTIVES List some of the characteristics of popular operating systems such as Windows 2000, UNIX, and Linux.

3 ©Brooks/Cole, 2003 Figure 7-1 Computer System

4 ©Brooks/Cole, 2003 DEFINITIONDEFINITION 7.1

5 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. Note:

6 ©Brooks/Cole, 2003 EVOLUTIONEVOLUTION 7.2

7 Evolution-- Batch systems Batch systems Batch systems Each program to be executed was called a job. Each program to be executed was called a job. A programmer who wished to execute a job sent a request to the operating room along with punched cards for the program and data. A programmer who wished to execute a job sent a request to the operating room along with punched cards for the program and data. Operating systems only ensured that all of the resources were transferred from one job to the next. Operating systems only ensured that all of the resources were transferred from one job to the next.

8 Evolution--Time-sharing systems Multiprogramming Multiprogramming to hold several jobs in memory to hold several jobs in memory only assign a resource to a job that needs it on the condition that the resource is available. only assign a resource to a job that needs it on the condition that the resource is available. Time sharing Time sharing Resource can be shared between different jobs Resource can be shared between different jobs Scheduling Scheduling OS allocates the resources to different programs and deciding which program should use which resource when. OS allocates the resources to different programs and deciding which program should use which resource when. Process Process A job is a program to be run, a process is a program that in memory and waiting for resources. A job is a program to be run, a process is a program that in memory and waiting for resources.

9 ©Brooks/Cole, 2003 Evolution (cont.) Personal systems Personal systems Single-user operating systems Single-user operating systems Example: DOS (disk operating system) Example: DOS (disk operating system) Parallel systems Parallel systems Multiple CPUs on the same machine Multiple CPUs on the same machine Distributed systems Distributed systems A program can be run partially on one computer and partially on another computer if they are connected through an internetwork. A program can be run partially on one computer and partially on another computer if they are connected through an internetwork.

10 ©Brooks/Cole, 2003 COMPONENTSCOMPONENTS 7.3

11 Figure 7-2 Components of an operating system A operating system has at least four duties: memory manager, process manager, device manager, and file manager. A operating system has at least four duties: memory manager, process manager, device manager, and file manager.

12 ©Brooks/Cole, 2003 Figure 7-3 Monoprogramming

13 ©Brooks/Cole, 2003 Memory manager (1) Monoprogramming Monoprogramming OS load a program, run it, and then replace it with the next program. OS load a program, run it, and then replace it with the next program. Only one program is in memory for execution. Only one program is in memory for execution. Problems: Problems: The program must fit in memory. The program must fit in memory. When one program is being run, no other program can be executed. When one program is being run, no other program can be executed.

14 ©Brooks/Cole, 2003 Figure 7-4 Multiprogramming

15 ©Brooks/Cole, 2003 Figure 7-5 Categories of multiprogramming

16 ©Brooks/Cole, 2003 Memory manager (2) Multiprogramming--Nonswapping Multiprogramming--Nonswapping Partitioning (Fig. 7.6) Partitioning (Fig. 7.6) Memory is divided into variable length sections. Memory is divided into variable length sections. Each section or partition holds one program. Each section or partition holds one program. The CPU switches between programs The CPU switches between programs Problems: Problems: The size of the partitions has to be determined beforehand by the memory manager. The size of the partitions has to be determined beforehand by the memory manager. There may be some holes after programs are replaced by new ones. There may be some holes after programs are replaced by new ones.

17 ©Brooks/Cole, 2003 Figure 7-6 Partitioning

18 ©Brooks/Cole, 2003 Memory manager (3) Multiprogramming--Nonswapping Multiprogramming--Nonswapping Paging Paging Paging improves the efficiency of the partitioning. Paging improves the efficiency of the partitioning. Memory is divided into equally sized sections called frames. Memory is divided into equally sized sections called frames. The program is divided into equally sized sections called pages. The program is divided into equally sized sections called pages. Figure 7.7. Figure 7.7. Problem: the whole programs still needs to be in memory before being executed. Problem: the whole programs still needs to be in memory before being executed.

19 ©Brooks/Cole, 2003 Figure 7-7 Paging

20 ©Brooks/Cole, 2003 Memory manager (4) Multiprogramming--Swapping Multiprogramming--Swapping Demand paging Demand paging The program is divided into pages, but the pages can be loaded into memory one by one, executed, and replaced by another pages. The program is divided into pages, but the pages can be loaded into memory one by one, executed, and replaced by another pages. The size of pages are equal. The size of pages are equal. Demand segmentation Demand segmentation The program is divided into segments (main program and subprograms) that match the programmer ’ s view. The program is divided into segments (main program and subprograms) that match the programmer ’ s view.

21 ©Brooks/Cole, 2003 Memory manager (5) Multiprogramming--Swapping Multiprogramming--Swapping Demand paging and segmentation Demand paging and segmentation A segment may be too large to fit any available free space in memory. A segment may be too large to fit any available free space in memory. Memory can be divided into frames, and a module can be divided into pages. Memory can be divided into frames, and a module can be divided into pages. The pages of a module can then be loaded into memory one by one and executed. The pages of a module can then be loaded into memory one by one and executed.

22 ©Brooks/Cole, 2003 Figure 7-8 Virtual memory

23 ©Brooks/Cole, 2003 Process manager Program Program A program is a nonactive set of instructions written by a programmer and stored on disk. A program is a nonactive set of instructions written by a programmer and stored on disk. Job Job A program becomes a job from the moment it is selected for execution until it has finished running and becomes a program again. A program becomes a job from the moment it is selected for execution until it has finished running and becomes a program again. Process Process A process is a program in execution. A process is a program in execution.

24 ©Brooks/Cole, 2003 State diagram State diagram (Fig. 7.9) State diagram (Fig. 7.9) Hold state Hold state Ready state Ready state Running state Running state Waiting stage Waiting stage Terminated state Terminated state

25 Figure 7-9 State diagram with the boundaries between a program, a job, and a process

26 ©Brooks/Cole, 2003 Schedulers Job scheduler Job scheduler The job scheduler moves a job from the hold state to the ready state or from the running state to the terminated state. (Fig. 7.10) The job scheduler moves a job from the hold state to the ready state or from the running state to the terminated state. (Fig. 7.10) Process scheduler Process scheduler The process scheduler moves a process from one state to another. (Fig. 7.11) The process scheduler moves a process from one state to another. (Fig. 7.11)

27 ©Brooks/Cole, 2003 Figure 7-10 Job scheduler

28 ©Brooks/Cole, 2003 Figure 7-11 Process scheduler

29 ©Brooks/Cole, 2003 Figure 7-12 Queues for process management

30 ©Brooks/Cole, 2003 Queuing The policies to select the next jog or process: The policies to select the next jog or process: First in, first out (FIFO) (queue) First in, first out (FIFO) (queue) Shortest length first Shortest length first The one with highest priority The one with highest priority And so on... And so on...

31 ©Brooks/Cole, 2003 Process synchronization( 同時 ) Whenever resources can be used by more than one processes, you can have two situations: Whenever resources can be used by more than one processes, you can have two situations: Deadlock( 死結 ) Deadlock( 死結 ) Starvation( 饑餓 ) Starvation( 饑餓 )

32 ©Brooks/Cole, 2003 Figure 7-13 Deadlock

33 ©Brooks/Cole, 2003 Figure 7-14 Deadlock on a bridge

34 ©Brooks/Cole, 2003 Solutions of deadlock Deadlock occurs if the OS allows a process to start running without first checking to see if the required resources are ready and allows the process to hold it as long as it wants. Deadlock occurs if the OS allows a process to start running without first checking to see if the required resources are ready and allows the process to hold it as long as it wants. Solutions of deadlock Solutions of deadlock Not to allow a process to start running until the resources are free. Not to allow a process to start running until the resources are free. To limit the time a process can hold a resource. To limit the time a process can hold a resource.

35 ©Brooks/Cole, 2003 Deadlock occurs when the operating system does not put resource restrictions( 限制 ) on processes. Note:

36 ©Brooks/Cole, 2003 Four necessary conditions Four necessary conditions for deadlock: Four necessary conditions for deadlock: Mutual exclusion Mutual exclusion Only one process can hold a resource. Only one process can hold a resource. Resource holding Resource holding A process holds a resource even though it cannot use it until other resources are available. A process holds a resource even though it cannot use it until other resources are available. No preemption( 優先權 ) No preemption( 優先權 ) The OS cannot temporarily reallocated a resource. The OS cannot temporarily reallocated a resource. Circular waiting Circular waiting All process and resources involved form a loop. All process and resources involved form a loop.

37 Figure 7-15.a Starvation (1)

38 Figure 7-15.b Starvation (2)

39 Figure 7-15.c Starvation (3)

40 Figure 7-16 Dining philosophers

41 ©Brooks/Cole, 2003 Device manager The device manager is responsible for the efficient use on input/output devices. The device manager is responsible for the efficient use on input/output devices. The responsibilities of a device manager: The responsibilities of a device manager: Monitor every I/O device constantly to assure that the device is functioning properly. Monitor every I/O device constantly to assure that the device is functioning properly. Maintains a queue for each I/O device or one or more queues for similar I/O devices. Maintains a queue for each I/O device or one or more queues for similar I/O devices. Control the different policies for accessing I/O devices. Control the different policies for accessing I/O devices.

42 ©Brooks/Cole, 2003 File manager The responsibilities of a file manager: The responsibilities of a file manager: Control access to files. Control access to files. Supervise ( 監督 ) the creation, deletion, and modification of files. Supervise ( 監督 ) the creation, deletion, and modification of files. Control the naming of files. Control the naming of files. Supervise the storage of files. Supervise the storage of files. Be responsible for archiving ( 檔案保管 ) and backups. Be responsible for archiving ( 檔案保管 ) and backups.

43 ©Brooks/Cole, 2003 User interface Each OS has a user interface. Each OS has a user interface. Examples: Examples: UNIX  shell UNIX  shell Windows  window (graphical user interface, GUI) Windows  window (graphical user interface, GUI)

44 ©Brooks/Cole, 2003 POPULAROPERATINGSYSTEMSPOPULAROPERATINGSYSTEMS 7.4

45 Popular operating systems Windows 2000 Windows 2000 GUI, virtual memory, multiprogramming, integral networking capability, security features, … GUI, virtual memory, multiprogramming, integral networking capability, security features, … Unix Unix Portable, powerful set of utilities, device independent, … Portable, powerful set of utilities, device independent, … Multiprogramming, virtual memory, well-designed file and directory systems, and short commands. Multiprogramming, virtual memory, well-designed file and directory systems, and short commands. Linux Linux Close to Unix Close to Unix

46 ©Brooks/Cole, 2003 Key terms Batch operating system Batch operating system Deadlock Deadlock Demand paging Demand paging Demand paging and segmentation Demand paging and segmentation Demand segmentation Demand segmentation Device manager Device manager Distributed system Distributed system File manager File manager Frame Frame Hold state Hold state Job Job Job scheduler Linux Memory manager Monoprogramming Multiprogramming Operating system Page Paging Parallel system Partitioning Process Process manager

47 ©Brooks/Cole, 2003 Process scheduler Process scheduler Process synchronization Process synchronization Program Program Queue Queue Ready state Ready state Running stage Running stage Multiprogramming Multiprogramming Scheduling Scheduling Single-user operating system Single-user operating system software software Starvation State diagram Terminated state Time sharing UNIX User interface Virtual memory Waiting state


Download ppt "©Brooks/Cole, 2003 Chapter 7 Operating Systems. ©Brooks/Cole, 2003 Define the purpose and functions of an operating system. Understand the components."

Similar presentations


Ads by Google