Download Operating Systems: Concepts and Structure and more Lecture notes Operating Systems in PDF only on Docsity!
What Operating Systems Do
(^) An operating system is a program that manages a computer’s hardware. It also provides a basis for application programs and acts as an intermediary between the computer user and the computer hardware.
(^) To understand more fully the operating system’s role, we next explore operating systems from two viewpoints: that of the user and that of the system. - (^) User View - (^) The user’s view of the computer varies according to the interface being used.
What Operating Systems Do
(^) System View
(^) From the computer’s point of view, the operating system is the program most intimately involved with the hardware. In this context, we can view an operating system as a resource allocator.
(^) A computer system has many resources that may be required to solve a problem: CPU time, memory space, file-storage space, I/O devices, and so on. The operating system acts as the manager of these resources.
(^) An operating system is a control program. A control program manages the execution of user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices.
Memory Layout for Multiprogrammed System Figure 1.
Operating-System Structure
(^) The operating system picks and begins to execute one of the jobs in memory. Eventually, the job may have to wait for some task, such as an I/O operation, to complete.
(^) Multiprogrammed systems provide an environment in which the various system resources (for example, CPU, memory, and peripheral devices) are utilized effectively, but they do not provide for user interaction with the computer system.
Operating-System Structure
(^) A time-shared operating system allows many users to share the computer simultaneously. Since each action or command in a time-shared system tends to be short, only a little CPU time is needed for each user. As the system switches rapidly from one user to the next, each user is given the impression that the entire computer system is dedicated to his use, even though it is being shared among many users.
(^) In a time-sharing system, the operating system must ensure reasonable response time. This goal is sometimes accomplished through swapping , whereby processes are swapped in and out of main memory to the disk.
Operating-System Structure
(^) A more common method for ensuring reasonable response time is virtual memory , a technique that allows the execution of a process that is not completely in memory. The main advantage of the virtual-memory scheme is that it enables users to run programs that are larger than actual physical memory. Further, it abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory.
Operating-System Operations
(^) Without protection against these errors, either the computer must execute only one process at a time or all output must be suspect. A properly designed operating system must ensure that an incorrect (or malicious) program cannot cause other programs to execute incorrectly.
(^) In order to ensure the proper execution of the operating system, we must be able to distinguish between the execution of operating- system code and user-defined code. So we need two separate modes of operation: user mode and kernel mode (also called supervisor mode , system mode , or privilegedmode ).
Operating-System Operations
(^) A bit, called the mode bit , is added to the hardware of the computer to indicate the current mode: kernel (0) or user (1). With the mode bit, we can distinguish between a task that is executed on behalf of the operating system and one that is executed on behalf of the user. When the computer system is executing 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 a system call), the system must transition from user to kernel mode to fulfill the request. This is shown in Figure 1.10. As we shall see, this architectural enhancement is useful for many other aspects of system operation as well.
Operating-System Operations
(^) At system boot time, the hardware starts in kernel mode. The operating system is then loaded and starts user applications in user mode. Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel mode (that is, changes the state of the mode bit to 0). Thus, whenever the operating system gains control of the computer, it is in kernel mode. The system always switches to user mode (by setting the mode bit to 1) before passing control to a user program.
(^) The dual mode of operation provides us with the means for protecting the operating system from errant users—and errant users from one another. We accomplish this protection by designating some of the machine instructions that may cause harm as privileged instructions.
Operating-System Operations
(^) The concept of modes can be extended beyond two modes (in which case the CPU uses more than one bit to set and test the mode). CPUs that support virtualization frequently have a separate mode to indicate when the virtual machine manager (VMM) —and the virtualization management software—is in control of the system. In this mode, the VMM has more privileges than user processes but fewer than the kernel.
Operating-System Operations
(^) If the timer interrupts, control transfers automatically to the operating system. We can use the timer to prevent a user program from running too long. A simple technique is to initialize a counter with the amount of time that a program is allowed to run.