In a multitasking system, the operating system must ensure reasonableresponse time. A common method for doing so isvirtual memory, a tech-nique 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 torun programs that are larger than actualphysical memory. Further, it abstractsmain memory into a large, uniform array of storage, separatinglogical mem-oryas viewed by the user from physical memory. This arrangement freesprogrammers from concern over memory-storage limitations.Multiprogramming and multitasking systems must also provide a file sys-tem (Chapter 13, Chapter 14, and Chapter 15). The file system resides on asecondary storage; hence, storage management must be provided (Chapter 11).In addition, a system must protect resources from inappropriate use (Chapter17). To ensure orderly execution, the system must also provide mechanisms forprocess synchronization and communication (Chapter 6 and Chapter 7), and itmay ensure that processes do not get stuck in a deadlock, forever waiting forone another (Chapter 8).1.4.2Dual-Mode and Multimode OperationSince the operating system and its users share the hardware and softwareresources of the computer system, a properly designed operating system mustensure that an incorrect (or malicious) program cannot cause other programs—or the operating system itself—to execute incorrectly. In order to ensurethe proper execution of the system, we must be able to distinguish betweenthe execution of operating-system code and user-defined code. The approachtaken by most computer systems is to provide hardware support that allowsdifferentiation among various modes of execution.At the very least, we need two separatemodesof operation:user modeandkernel mode(also calledsupervisor mode,system mode, orprivilegedmode). A bit, called themode bit, is added to the hardware of the computerto indicate the current mode: kernel (0) or user (1). With the mode bit, we candistinguish between a task that is executed on behalf of the operating systemand one that is executed on behalf of the user. When the computer system isexecuting on behalf of a user application, the system is in user mode. However,when a user application requests a service from the operating system (via asystem call), the system must transition from user to kernel mode to fulfill
1.4Operating-System Operations25user process executinguser processkernelcalls system callreturn from system calluser mode(mode bit = 1)trapmode bit = 0returnmode bit = 1kernel mode(mode bit = 0)execute system callFigure 1.13Transition from user to kernel mode.the request. This is shown in Figure 1.13. As we shall see, this architecturalenhancement is useful for many other aspects of system operation as well.