페이지

2022년 4월 18일 월요일

1.4.1 Multiprogramming and Multitasking

 One of the most important aspects of operating systems is the ability to run multiple programs, as a single program cannot, in general, keep either the CPU or the I/O devices busy at all times. Furthemore, users typically want to run more than one program at a time as well. Multiprotramming increases CPU utilization, as well as keeping users satisfied, by oranizing programs so that the CPU always has one to execute. In a multiprogrammed system, a program in execution is termed a process.

The idea is as follows: The operaing system keeps several processes in memory simultaneously (Figure 1.12). The operating system picks and begins to execute one of these processes. Eventually, the process may have to wait for some task, such as an I/O operation, to complete. In a non-multiprogrammed system, the CPU would sit idle. In a multiprogrammed system, the operating system simply switches to, and executes, another process. When that process needs to wait, the CPU switches to another process, and so on. Eventurally, the first process finishes waiting and gets the CPU back, As long as at least one process needs to execute, t he CPU is never idle.

This idea is common in other life situations. A lawyer does not work for only one client at a time, for example. While one case is waiting to go to trial or have papers typed, the lawyer can work on another case. If she has enough clients, the lawyer will never be idle for lack of work. (Idle lawyers tend to become politicians, so there is a certain social value in keeping lawyers busy.)

Multitasking is a logical extension of multiprogramming. In multitasking systems, the CPU execute multiple processes by switching among them, but the switches occur frequently, providing the user with a fast response time. Consider that when a process executes, it typically executes for only a short time before it either finishes or needs to perform I/O. I/O may be interactive; that is, output goes to a sidplay for the user, and input comes from a user keyboard, mouse, or touch screen. Since interactive I/O typically runs at "people speeds," it may taske a long time to complete. Input, for example, may be bounded by the user's typing speed; seven characters per secound is fast for people but incredibly slow for computers. Rather than let the CPU sit idle as this interactive input taskes place, the operating system will repidly switch the CPU to another process.

Having serral processes in memory at the same time requires some form of memory management, which we cover in Chapter 9 and Chapter 10. In addition, if serveral processes are ready to run at the same time, the system must choose which process will run next. Making this desicion is CPU scheduling, which is discussed in Chapter 5. Finally, running multiple processes concurrently requires that their ability to affect one another be limited in all phases of the operating system, including process scheduling, disk storage, and memory management. We discuss these considerations throughout the text.

In a multitasking system, the operating system must ensure reasonable response time. A common method for doing so is virtual memroy, a technique that allows the execution of a process that is not completely in memory(Chapter 10). The main advantage of this scheme is that it enables users to run programs that are larger than actural physical memory. Futher, it abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory. This arragement frees programmers from concern over memory-storage limitations.

Multiprogramming and multitasking system must also provide a file system(Chapter 13, Chapter 13, and Chapter 15). The file system resides on a secondary storage; hence, storage management must be provided(Chapter 11). In addition, a system must protect resources from inappropriate use (Chapter 17). To ensure orderly execution, the system must also provide mechanisms for process synchronization and communication(Chater 6 and Chapter7), and it may ensure that processes do not get stuck in a deadlock, forever waiting for one another(Chapter 8).


댓글 없음: