Introduction: - An Operating System is a program that acts as an intermediary between a user of a computer and the computer hardware. i.e. a control program that controls the execution of user programs to prevent errors and improper use of the computer. - The purpose of an OS is to provide an environment in which a user can execute programs. - Primary goal is make the computer system convenient to use. - Secondary goal is to use the computer hardware in an efficient way. - A computer system can be divided into 4 components: + Hardware (CPU, memory, I/O: provides the basic computing resources) + Operating System (controls and coordinates the use of the H/W among the various application programs for the various users) 1 + Application programs (compilers, DBs, games, business programs: define the ways in which these resources are used to solve the users computing problems) + Users (people, machines, other computers trying to solve different problems) Banking Airline Web system reservation browser Compilers Editors Command Interpreter Operating system Machine language Microprogramming Physical devices - We can view an OS as a resource allocator, which acts as manger of resources (H/W: physical resources; S/W: logical resources) and tries to allocate them to specific programs and users as necessary for tasks. 2 - Another view of an OS focuses on the need to control the various I/O devices and user programs. - In general, there is no completely adequate definition of an OS. Batch Systems: - In these systems the user does not interact directly with the computer systems while the job is executing. - He prepares a job ((program + data) and control cards), and submits it to the computer operator. - The OS in these systems was fairly simple. - To speed up processing, jobs with similar needs were batched together and run as a group. - A batch OS reads a stream of separate jobs (from card reader), each with its own control cards that predefine what the job does. 3 - When a job is complete. Its output is usually printed (on line printer). - In his execution environment, the CPU is often idle. - This idleness occurs because the speeds of the mechanical I/O devices are slower than those of electronic devices. (CPU works (1000s of instruction per second, CR, reads 1200 cards per minute i.e. 17 cards per second)). - The relative slowness of the I/O devices can mean that the CPU is often waiting an I/O. - The problem is that: “ while an I/O operation is occurring, the CPU is idle, waiting for the I/O to complete, while the CPU is executing, the I/O devices are idle.” - The CPU was still faster than the I/O devices. Buffering is used to solve the problem of slowness of I/O devices. The idea is: 4 “After data has been read and the CPU is about to start operating on it, the input device is instructed to begin the next input immediately”. The CPU and I/O devices are both busy. Spooling (Simultaneous Peripheral Operation On-Line) The introduction of disk technology has helped in this regard. Essentially uses the disk as a very large buffer for reading as far a head as possible on input devices and for storing output files until the output devices are able to accept them. Spooling overlaps the I/O of one job with the computation of other jobs. The spooler may be reading the input of one job while printing the output of different job. During this time still another job(s) may be executed. Spooling can keep both the CPU and I/O devices working at much higher rates. 5 Multiprogramming:( memory partition) - Spooling provides a very important data structure: a job pool. - When several jobs are on a disk, job scheduling becomes possible. - The main aspect of job scheduling is the ability to multiprogram. - Multiprogramming increases CPU utilization by organizing jobs such that the CPU always has on to execute. - The idea: The OS keeps several jobs in memory at a time. This set of jobs is the subset of the jobs kept in the job pool. The OS picks and begins to execute one. Eventually, the job may have to wait for some task (I/O operation to complete). The OS switches to another job and execute it, when that needs to wait, the CPU switches to another and so on. When the 1st job finishes waiting it will get the CPU back. The CPU will never be idle as long as there is job to be executed. 6 Time Sharing: (multitasking) (Interactive Systems) - A time-shared OS allows the many users to simultaneously share the computer. - Multiple jobs are executed by the CPU switching between them executes multiple jobs; so that, the user may interact with his program while it is running. - A time-shared OS uses CPU scheduling and multiprogramming to provide each user with a small portion of a time-shared computer. - Each user has a separate program in memory. - When it executes, it will execute for a short time before either finishes or needs I/O. I/O may be interactive (output to display, input from keyboard). During that it will switch to another job. Personal Computer Systems (PCs) - It is a system that is dedicated to a single user. 7 - The goal of these OSs is: instead of maximizing CPU and peripheral utilization, the system chooses maximizing user convenient and responsiveness. - CPU utilization is no longer a prime concern. Parallel Systems: - Most systems to date are single-process systems (i.e. they have only one main CPU). - There is a trend toward multiprocessor systems. - Such systems have more than one processor in close communication, sharing the computer bus, the clock, and sometimes memory and peripheral devices. - These systems are referred as tightly coupled systems. - There are several reasons for building such systems: 8 One advantage is increase throughput: By increasing the number of processors, we hope to get more work done in a shorter period of time. Multiprocessors can save money compared to multiple single systems, because the processors can share peripherals, cabinets, and power supplies. Another reason is that, they increase reliability. - If functions can be distributed properly among several processors, then the failure of one processor will not halt the system, but rather will only slow it down. 9 Distributed Systems: - A recent trend in computer system is to distribute computation among several processors (sites, nodes, computers) - The processors do not share memory or a clock, but each processor has its own local memory, which communicates with each others through various communication lines (high-speed buses and telephone lines). We call it site (small microprocessors, workstations, generalpurpose computers) - These systems are referred as loosely coupled systems or distributed systems. - The major reasons for building these systems are: + Resource sharing (user of one site can use resources of another site) + Computation speedup (1. If a problem computation partitioned sub computation run concurrently then can distributed among sites. 2. If one site is overloaded move some to other sites load-sharing) 10 + Reliability: If one site failed, the other can continue operating. + Communications: If sites are connected by network, processes can exchange information between them. Real-Time Systems:(Special Purpose OS) - It is used when there are rigid time requirements on the operation of a process or the flow of data and used as a control device. - Systems that control scientific experiments, medical imaging, and industrial control are real-time systems. - Processing must be dome within the defined constraints, or the system will fail. 11