Transcript for:
Understanding Multitasking and Multiprogramming

Hello! We move to the multi-programming and multitasking. One of the most important aspects of operating system is ability to run multiple programs. So a single program cannot in general keep either CPU or your device busy all the time. So for the more users typically wants to run more than one program and same as well. So, multiprogramming increases CPU utilization as well as keeping users satisfied by organizing programs so that CPU always has one to execute. In a multiprogramming system, a program in execution is termed as process. The idea is to follow the program, system keeps several processes and memory simultaneously, as you see on the picture. The operating system picks and begins to execute one of these processes. Eventually, the process may have to wait for some task, such as your operation to complete. In non-multiprogramming system, the CPU would sit idle. In multiprogram system, the operating system simply switches to and executes another process. When the end process needs to wait, The CPU switched to another process and so on. Eventually the first process finish waiting and get CPU back. As long as least one process needs to execute, the CPU is never idle. So this idea is common in another life situation. Allower does not work only one client at a time. For example, while one case is waiting to go to trail, have papers typed. and the Lauer can work on another case. If she has enough clients, the Lauer will never idle for lack of work. Multitasking is a logical extension of multiprogramming, and multitasking system CPU executes multiple processes by switching among them. But switches occur frequently, providing the user with fast response time. Consider that when process executes, It typically executes for only a short time before it either finishes or needs to perform operating I.O. and input output may be interactive, that is, output does to to a display for the user. An input comes from user keyboard mouse. Since interactive typically runs people speeds, it may take a long time to complete. Input, for example, may be bounded by the user typing speed 7 characters per second and fast for people, but incredibly slow for computers. Rather than let the CPU sit idle as the interactive input takes place, the operating system will repeatedly switch CPU to another process. Failing several processes in memory and same time requires some form of memory management, which we will cover later. In addition, if several processes are ready to run, at the same time the system must choose which process will run next. Making this decision, the CPU scheduling which we will discuss later, the final running multiple processes concurrently requires that the ability to affect one and another be limited on phases of the operating system. including process scheduling, storage and memory management. Okay, in multitasking systems, the operating system must ensure reasonable response time. The common method of doing is virtual memory, a technique that allows execution for processes that are not completely in memory. The main advantage of this scheme is that it enables users to run programs that are larger than their physical memory. Main memory into large uniform array of storage separating long-weak memory is viewed by the user from physical memory. This arrangement frees programs from concern over memory storage limitations. A multiprogramming and multitasking system must also provide a file system. The file system resides in secondary storage, hence storage mounds must be provided. An additional system must protect secure for inoperate users. So, in order of execution, the system must also provide mechanism to process synchronization and communication, and it may ensure that process does not get stuck in deadlock, forever waiting for one another. So, next slide. Since the operating system and its users share the hardware and software resources of the computer system, A properly designed operating system must ensure that an incorrect program cannot cause other programs or operating system itself to execute incorrectly. In order to ensure the proper execution of the system, we must able to discuss between the execution operating system code and user-defined code. The approach taken by most computer systems is to provide hardware support that allows differentiation among various modes of execution. At very last we need to separate modes of operation, user mode and kernel mode. A bit called the mode bit is added to the hardware of the computer to indicate the current mode, kernel or user. With the mode bit we can distinguish between task is executed on behalf of the operating system and one that is executed on behalf of the user. When this computer system is executed on behalf of user application, the system is in user mode. However, when a user application requests service from operating system, the system must transition from user to kernel mode to fulfill the request. So, as you see on the picture, this architectural enhance is useful for many other aspects of system operation as well. At system boot time, the hardware starts in kernel mode. The operating system is then loaded and starts user application in user mode. Whatever trap or interrupt occurs, the hardware switches from user mode to kernel mode. Thus, whatever the operating system gains control of the computer, it's in kernel mode. The system always switches to user mode by setting on mode bit 1 before passing control to a user program. The dual mode of operation provides us with the means of protecting operating system from a RAND user and a RAND user from one another. We accomplish this protection by designing a sum of machine interactions that may cause harm as privileged interactions. The hardware allows privilege instruction to be executed only in kernel mode. If an attempt is mode execute privilege instruction in user mode, the hardware does not execute the instruction but rather treats as illegal and traps into the operating system. The instruction to switch to kernel mode is an example of privilege instruction. Some other examples include I-O control, timer management, and trap management. Many additional privileged instructions we will discuss. The concept of modes can be extended beyond two modes. For example, inter-processor have four separate protection rings, where the zero is kernel mode and ring three is user mode. Also, rings one and two could be used for various operating systems, services and practices they are rarely used. REM system has 7 modes CPU, the support virtualizations. Frequently have separate mode to indicate when virtual machine manager is controlled of the system. In this mode VMM has a privilege has that user process but fewer than the kernel. It needs that level of privilege so it can create and manage virtual machines changing CPU states. and so on. Well, next we must ensure that operating system maintain control over the CPU. So we cannot allow user program to get stuck in infinite loop of file to call system service and never return control in the operating system. To accomplish this goal we can use a timer. A timer can be set to interrupt the computer after a specified period. The period may be fixed or variable example from 1 millisecond to 1 second. Variable timers generally implemented by fixed rate clock and counter. Operating system sets the counter every time clock ticks the counter is discriminated. When the counter reaches zero, an interrupt occurs. For instance, 10-bit counter with 1 millisecond clock also interrupts an interval from 1 millisecond to 1024 millisecond in step of 1 millisecond. So the next slide is process management. So we impose that program by itself is not process. Yeah, a program is process entity like contents of file stored on disk, whereas process is an active entity. A single treated process has one program counter specifying the next instructions to execute. So the operating system is responsible for following activities connection with process management. creating deleting boss user system process scheduling processor trades on cpus suspending and resuming processes providing mechanism first process synchronization and providing mechanism for post communication so as we know program cannot do nothing unless it's instruction executed by cpu a program in execution As mentioned, it is a process. Programs such as Copillar are a process and would work processing program being run by individual user. So PC on the Pace process. Yeah, so similar of social media apps, mobile devices, a process. For now you can consider process to be an instance for program in execution. But later you will see this concept is more general. So it's possible to provide system calls that allow process to create subs process to execute concurrently. A process needs certain resources including CPU time, memory, files, I.O devices to accomplish its task. These resources are typically allocated to process while it's running. In addition to the various physical and logical resources that a process obtains when it is created. Various centralization data may be passed along. For example, consider process running in web browser whose function is to display the content of web page on the screen. The process will be given the URL as an input and will execute the appropriate instruction and system called top10 and displays the desired information on the screen. When process terminates, the operating system will reclaim any reasonable resources. Next, file system management. To make the computer system convenient for users, the operating system provides a uniform logical view of information storage. The operating system abstracts from the physical properties of its storage devices to define a logical storage unit. The operating system maps files into physical media and accesses files via storage devices. While management is one of the most visible components of an operating system, computer can store information on several different types of physical media. Secondary storage is the most common, but tertiary storage is also possible. Each of these media has its own characteristic and physical organization. Most are controlled by devices such as disk drive that also has its own unique characteristic. These properties include access speed, capacity, data transfer rate, and access method. A file is a collection related information defined by its creator. Commonly file represent programs and data. Data files may be numeric, alphabetic, alphabetic and binary. Files may be freeform. They may be preformatted rigidly. Fixed fields such as mp3 can be example. Clearly, the concept of file is an extremely general one. The printing system implements the abstract concept of file by managing mass storage media and the device it controls there. Additional files are normally organized into directories to make them easier to use. Finally, when multiple users have access to files, it may be desirable to control which user may access file and how this user may access it. As we have already seen, the computer system must provide secondary storage to backup main memory. Most modeling computer systems use HDD, NVM devices, principle online storage media both programs and data most programs include compilers web browsers small processors and games and storage this device until loaded into memory the programs when you use device both search and destination of the process hence the program of secondary storage is of the central importance to computer system because because secondary storage is used frequently extensively it must be used efficiently. The entire speed of operations of the computer may hide on the speed and secondary storage. So, system and algorithms that manipulate the subsystem. At the same time, the remaining user for storage is lower and lower in cost than secondary storage. Backups of disk data storage and seldom user data and long term actual storage are some examples. Magnetic tapes, drives and their tapes and some CD, Bollary drives and platters, typically theoretical storage devices. Tertiary storage is not crucial to system performance, but it still must be managed. Some operating system take on this task while other leave. territory storage management to application programs. Some of the functions operating system can provide include monitoring and monitoring media and devices, allocating and feeing the device for execute use by processes and migrating data from secondary to the territory storage. Caching is an important principle of computer system. Here's how it works. Information is normally kept in some storage system. As it's used, it's copied into a faster storage system, the cache, on a temporary basis. When we need a particular piece of information, we first check whether it is in the cache, if we use the information directly from the cache, if it's not, we use information from the source. putting on copy cache under the assumptions that we will need it again soon. In addition, internal program registers provide a high-speed cache for main memory. The program implements a registered location and registered replacement algorithm to decide which information to keep in register and which to keep in main memory. Other cache can be implemented totally in hardware. For instance, most systems have interaction cache to hold the instruction expected to be executed next. Without that cache, the CPU would have to wait several cycles while the instruction was fetched from main memory. For similar reasons, most systems have one or more high-speed data cache in memory or archive. We are not concerned that this hardware only caches in the TX, since they outside the control of operating system. Because cache have limited size, cache management is important design problem. Carve early selection of cache size and whole of our replacement policy can result in greatly increased performance, as you can see on this picture. Replacements algorithm for software-controlled caching we'll discuss later. The movement of operation information between levels of storage hierarchy may be either explicit, implicit, depending on hardware design and the controlling operating system software. For instance, that the transfer for cached CPU and registers usually hardware functions with no operating system intervention. In contrast, transfer of data from disk to memory is usually controlled by the operating system. In a error-held storage structure, the same data may appear in different levels on the storage system. For example, suppose that an integer a that is to be incremented by one is located in file b, and file b resides on the hard disk. The increment operation proceeds by first issuing an EU operation to copy the disk block on which R resides to main memory. This operation is followed by copy R to cache and an internal register. Those the copy of IPs several places on the hard disk in main memory in the cache and internal register. Once the interim and task place in the internal register, the value of five differs in various storage system. In computing environment where only one process executes on a time, the surrounding process no difficulties. Since access to integer r will always be the copy at the highest level of the hierarchy. However in multitasking environment where CPU is switched back and forth among various processes, extreme care must be taken to ensure that the data is stored in the right place. process wish to access R, then each of these processes will obtain the most recently updated value of R. The situation becomes more complicated in multiprocessor environment where in addition to maintaining internal registers, each of these CPUs also contains a local cache. And such an environment, the copy of R may exist simultaneously in several caches. Since the various CPUs can all execute in parallel, we must make sure that update to the value of R in one cache is immediately reflected to other caches where R resides. This situation is called cache coherency and it's usually hardware issue. It's in distributed environment this situation becomes even more complex. In this environment, several copies of the same file can be kept in one different computer. Since various replicas may access to an update concurrently, some distributed system ensures that when replica is updated in one place, all other replicas are brought up to date as soon as possible. Protection then is any mechanism for controlling the access of processor users to the resource defined by computer system. This mechanism must provide means to specify the control to impose and enforce the controls. Protection can improve reliability by detecting latent and gross interfaces between components subsystems. Early detection of interface errors can often prevent contamination of a healthy subsystem by another subsystem. that is malfunctioning. Furthermore, an unprotected resource cannot defend against use by an authorized or incompetent user. In some circumstances, we wish to distinguish among sets of users rather than individual users. For example, the owner file of Unix system may be allowed to ensure operations on that file. file where a selected set of users may be allowed only read the file. To accomplish this, we need to define group name and set of users belonging to that group. Group functionality can be implemented as system-wide list of the group names in group identifier. Virtualization The technology is used to abstract the hardware of a single computer into several different execution environments, terribly creating illusions that each separate environment is running on its own private computer. These environments can be viewed as different to individual operating systems that may be running at the same time and may interact with each other. A user of virtual machine can switch among the various operating systems in same way of a user can switch among the various process running concurrently in a single operating system. Windows was the host operating system and the VMWire application was virtual machine manager. ZmvVM runs gas operating system, manage the resource use and protects each gas from the others. Even some monitoring operating systems are fully capable of running multiple applications, reliable use of virtualization continues to grow. On laptop's desktop, EM-Olofsen user install multiple operating systems for exploration, run applications written for operating systems as its native host. For example, in Apple laptop running Mac OS on x86 CPU you can run Windows 10 guest to all execution of Windows application. Companies writing software for multiple operating system can use virtualization to run all those operating system on single physical server development testing and debugging. Within data centers virtualization has become common method of executing and managing computing environments. So, VMM or VMWire has no run on host operating system, but rather host operating system providing service to resource management to virtual machine processes. With this tech we provide Linux virtual machine that allows you to run Linux as well as the devolved tools we provide on your personal system, regardless operating system. So, in summary, an operating system is software that manages computer hardware as well as providing environment for application programs to run. Interrupts are key way in which hardware interacts with an operating system. A hardware device triggers an interrupt by sending signal to the CPU. Alert CPU some event requires attention. The interrupt is managed by interrupt handler. For a computer to do its job executing programs, the program must be main memory, which only large storage area that process can access directly. The main memory is usually volatile storage device that losses its contents when power is turned off or lost. Non-volatile storage is an executation of main memory and is capable of holding large quantities of data permanently. The most common non-volatile storage device is a hard disk, which can provide storage both programs and data. Modern computer architecture is a multiprocessor system in which each CPU contains several computing cores. To best utilize CPU, modern operating systems employ multiprogramming, which allows several jobs to be in memory at the same time. thus ensuring that the CPU always has jobs to execute. Multitasking is an extension of multiprogramming, wherein CPUs schedule algorithms rapidly, switch between processes, providing users with fast response time.