Operating System

  • View

  • Download

Embed Size (px)



Text of Operating System

  • 1. Operating system For a computer to be able to operate a computer programme (sometimes known as application or software), the machine must be able to perform a certain number of preparatory operations to ensure exchange between the processor, the memory and the physical resources (peripherals).The operating system (sometimes referred to by its abbreviation OS), is responsible for creating the link between the material resources, the user and the applications (word processor, video game, etc.). When a programme wants to access a material resource, it does not need to send specific information to the peripheral device but it simply sends the information to the operating system, which conveys it to the relevant peripheral via its driver. If there are no drivers, each programme has to recognise and take into account the communication with each type of peripheral!The operating system thus allows the "dissociation" of programmes and hardware, mainly to simplify resource management and offer the user a simplified Man-machine interface (MMI) to overcome the complexity of the actual machine.Serial processingThe earliest computer system has no OS at all, and is characterized as serial processing because users have to reserve time slots in advance, and during the alloted period, they occupy the computer exclusively. Thus the computer will be used in sequence by different users.These early systems presented two major problems:1. Users may finish their tasks earlier than you have expected, and unfortunately the rest time is simply wasted. Or they may run into problems, cannot finish in the allotted time, and thus are forced to stop, which causes much inconvenience and delays the development.2. In such systems, programs are presented by cards. Each card has several locations on it, where there may be a hole or not, respectively indicating 0 or 1. Programs are loaded into memory via a card reader. With no OS available, to compile their programs, users have to manually load the compiler program first with the user program as input. This involves mounting, or dismounting tapes or setting up card decks. If an error occurred, the user has to repeat the whole process from the very beginning. Thus much time is wasted.Simple batch systems To improve the utilization of computer systems, the concept of a batch operating system was developed later on. The central idea is the use of a piece of software known as the monitor. With it, users dont have direct access to the computer systems any longer; instead, the operator of the system collects the user programs and batches them together sequentially for use by the monitor. To process user programs, the monitor first has to be loaded into memory. Then it reads in programs one at a time from the input devices. As each program is read in, it will be placed in the user program area of main memory, and control is passed to this program. When the execution of the program is completed, it returns control to the monitor, which moves on to process the next program.Multiprogrammed batch systemsEven with the automatic job processing by a monitor, the processor is still often idle. The problem is actually what we have discussed before regarding programmed I/O. That is a program may have to wait for I/O operation to

2. finish and thus leads to the processors idling. The solution is to run multiple programs concurrently during a certain period so that whenever the current program has to wait for I/O devices, control may be transferred to another program. If needed, a third program may be loaded, or even more. This scheme is called multiprogramming or multitasking. With multiprogramming, the utilization of processor is greatly improved, but it has its own problems. To run multiple programs concurrently, the memory should be organized properly so that each program has its own space and does not invade others. Whats more, at some moment, there may be more than programs ready to run. Thus some form of scheduling is needed to obtain better performance.Time-sharing system With multiprogramming, the overall system is quite efficient. However a problem remains. That is those jobs that come late in the batch job list wont get chance to run until the jobs before them have completed, thus their users have to wait a long time to obtain the results. Some programs may even need interaction with users, which requires the processor to switch to these programs frequently. To reach this new goal, a similar technique to multiprogramming can be used, called time sharing. In such a system, multiple users simultaneously access the system through terminals, with the operating system interleaving the execution of each user program in a short burst of computation. For example, suppose a computer system may have at most 10 users at the same time, and the human reaction time is 200 ms. Then we may assign 200/10 = 20ms CPU time to the user programs one by one in a cyclic manner, thus each user will be responded within the human reaction time so that the computer system seems to service the user program itself.The following table gives the difference between the batch multiprogramming and time sharing:System callA system call is a request made by any program to the operating system for performing tasks -- picked from a predefined set -- which the said program does not have required permissions to execute in its own flow of execution. System calls provide the interface between a process and the operating system. Most operations interacting with the system require permissions not available to a user level process, e.g. I/O performed with a device present on the system or any form of communication with other processes requires the use of system calls.The fact that improper use of the system call can easily cause a system crash necessitates some level of control. The design of the microprocessor architecture on practically all modern systems (except some embedded systems) offers a series of privilege levels -- the (low) privilege level in which normal applications execute limits the address space of the program so that it cannot access or modify other running applications nor the operating system itself. It also prevents the application from directly using devices (e.g. the frame buffer or network devices). But obviously many normal applications need these abilities; thus they can call the operating system. The operating system executes at the highest level of privilege and allows the applications to request services via system calls, which are often implemented through interrupts. If allowed, the system enters a higher privilege level, executes a specific set of instructions which the interrupting program has no direct control over, then returns control to the former flow of execution. This concept also serves as a way to implement security. With the development of separate operating modes with varying levels of privilege, a mechanism was needed for transferring control safely from lesser privileged modes to higher privileged modes. Less privileged code could not simply transfer control to more privileged code at any point and with any processor state. To allow it to do so would allow it to break security. For instance, the less privileged code could cause the higher privileged code to execute in the wrong order, or provide it with a bad stack. 3. Interrupt Processing An interrupt is a dynamic event that needs prompt attention by the CPU. Usually an interrupt only needs a short period of CPU time to serve it. After that the original process can resume its execution. There are two types interrupting events: hardware interrupts that are those issued by I/O device controllers when they need CPU to process I/O data, and software interrupts, also called traps, that are raised when the current process executes a special trap instruction to indicate that something wrong has happened or the process needs special service from the operating system (like performing some I/O operation). Only a limited number of types of interrupts are defined. For each type of I/O devices, there is a special program called an interrupt handler to serve the interrupt requests from these devices. For all software traps, there is also a special trap handler defined. Each type of interrupt has an associated priority level. A running process would only be interrupted by an interrupt source or trap of higher priority. When the CPU is executing an interrupt handler, the interrupt handler may be further interrupted by an interrupt source of even higher priority.As we mentioned earlier, each type of interrupts will be processed by its own special interrupt handler. These interrupt handlers are an important component of an operating system. The starting address of each of these interrupt handlers are saved in a table called an Interrupt Vector. The Interrupt Vector is usually stored at the lower end of the main memory, starting from address 0. Suppose an I/O device has ID 3, then the starting address of its interrupt handler is in memory address 3.Upon entering the interrupt processing phase, the following events will happen: a. Reset (put 0 in) the Interrupt Enabled Bit to disable further nested interrupting b. The hardware will automatically push all the values of the program counter and general purpose- registers into a system stack c. Suppose the Address Lines of the system bus is now carrying k, where k is a small integer, the kth memory words value (the starting address of the interrupt handler for the current interrupt source) will be loaded into the CPU program counter, and the CPU starts to run the interrupt handler.The interrupt handler will do the following steps:a. If necessary, save more state information for the interrupted process. For example, maybe the carry bit of the ALU is needed by this handler thus needs to be saved.b. Set (put 1 in) the Interrupt Enabled Bit to enable further nested interruptingc. Do the necessary proc


View more >