3.1.a The Main Features of Operating Systems
The operating system (OS) must provide and manage hardware resources as well as provide an interface between the user and the machine and between applications software and the machine. The OS must also provide other services such as data security.
Originally, if a program needed input, the program would have to contain the code to do this, similarly if output were required. This led to duplication of code so the idea of an OS was born. The OS contained the necessary input and output functions that could be called by an application. Similarly, disk input and output routines were incorporated into the OS. This led to the creation of subroutines to do these simple tasks such as read a character from a keyboard or send a character to a printer. The joining together of all these basic input and output routines led to the input-output control system (IOCS).
Originally, the IOCS could only read a punched card or send data to a card punch. However, as new input and output media, such as magnetic tape and disk, were developed the IOCS became more complex.
Another complication was added when assembly and high-level languages were developed as the machine did not use these languages. Machines use binary codes for very simple instructions. With the development of these new types of programming language a computer would have to
• load an assembler, compiler or interpreter,
... results. Natural Language Processing using machine learning. Modern NLP algorithms are based on machine learning, especially statistical machine learning. The ... defined to evaluate an NLP system by comparing its output with the gold standard (or desired) one. ... enabling computers to derive meaning from human or natural language input. An automated online assistant providing customer service on ...
• load the assembly or high-level program,
• do the translation,
• store the results somewhere in memory,
• execute the program,
• read input data,
• output the results.
For a user to organise all this had now become too complex. Also, as the processor could work much faster than the manual operator and the input and output devices, much time was wasted.
Further, to make full use of the processor, more than one program should be stored in memory and the processor should give time to each of the programs. Suppose two programs are stored in memory and, if one is using an input or output device (both very slow compared to the processor), it makes sense for the other program to use the processor. In fact this can be extended to more than two programs as shown in Fig. 3.1.a.1.
The OS must now manage the memory so that all three programs shown in Fig. 3.1.a.1 are kept separate as well as any data that they use. It must also schedule the jobs in the sequence that makes best use of the processor.
This is satisfactory so long as nothing goes wrong. Unfortunately things do go wrong and sometimes the normal order of operation needs to be changed. For example, a user has used up all the time allocated to his use of the processor. This change in order is instigated by interrupts. The nature of each of these interrupts is
• I/O interrupt
o Generated by an I/O device to signal a job is complete or an error has occurred. E.g. printer is out of paper or is not connected.
• Timer interrupt
o Generated by an internal clock indicating that the processor must attend to time critical activities (see scheduling later).
• Hardware error
o For example, power failure which indicates that the OS must close down as safely as possible.
• Program interrupt
o Generated due to an error in a program such as violation of memory use (trying to use part of the memory reserved by the OS for other use) or an attempt to execute an invalid instruction (such as division by zero).
If the OS is to manage interrupts, the sequence in Fig. 3.1.b.1 needs to be modified as shown in Fig. 3.1.b.2.
Is there an interrupt?
... , loop, or instructions are completed, the next statement in sequence will be executed. What is branching within a program? Branching is similar ... a series of consecutive statements which is executed in the order that they instructed. The computer only operates on sequential code ...
Service the interrupt
Any more instructions?
This diagram shows that, after the execution of an instruction, the OS must see if an interrupt has occurred. If one has occurred, the OS must service the interrupt if it is more important than the task already being carried out (see priorities later).
This involves obeying a new set of instructions. The real problem is ‘how can the OS arrange for the interrupted program to resume from exactly where it left off?’. In order to do this the contents of all the registers in the processor must be saved so that the OS can use them to service the interrupt. Chapter 3.3 explains registers that have to have their contents stored as well as explaining the fetch/execute cycle in more detail.
Another problem the OS has to deal with happens if an interrupt occurs while another interrupt is being serviced. There are several ways of dealing with this but the simplest is to place the interrupts in a queue and only allow return to the originally interrupted program when the queue is empty. Alternative systems are explained in Section 3.1.c. Taking the simplest case, the order of processing is shown in Fig.3.1.b.3.
Is there an interrupt
in the interrupt queue?
Service the next interrupt
in the interrupt queue
The queue of interrupts is the normal first in first out (FIFO) queue and holds indicators to the next interrupt that needs to be serviced.
One of the tasks of the OS is to arrange the jobs that need to be done into an appropriate order. The order may be chosen to ensure that maximum use is made of the processor; another order may make one job more important than another. In the latter case the OS makes use of priorities.
Suppose the processor is required by program A, which is printing wage slips for the employees of a large company, and by program B, which is analysing the annual, world-wide sales of the company which has a turnover of many millions of pounds.
Program A makes little use of the processor and is said to be I/O bound. Program B makes a great deal of use of the processor and is said to be processor bound.
If program B has priority over program A for use of the processor, it could be a long time before program A can print any wage slips. This is shown in Fig. 3.1.c.1.
... as possible. Some rules-of-thumb: Allow enough time at your old job. The old two-weeks notice is still standard, and ... for accusations if you are leaving under bad circumstances. Simply state that you are leaving and why (perhaps your new position ... place. She was living in Iowa at the time and was contacted about a job in Florida. After several phone interviews, she ...
Fig. 3.1.c.2 shows what happens if A is given priority over B for use of the processor. This shows that the I/O bound program can still run in a reasonable time and much better throughput is achieved.
The objectives of scheduling are to
• maximise the use of the whole of the computer system;
• be fair to all users;
• provide a reasonable response time to all users, whether they are on-line users or a batch processing user;
• prevent the system failing if it is becoming overloaded;
• make sure that the system is consistent by always giving similar response times to similar activities from day to day.
To achieve these objectives some criteria are needed in order to determine the order in which jobs are executed. The following is a list of criteria, which may be used to determine a schedule, which will achieve the above objectives.
• Priority. Give some jobs a greater priority than others when deciding which job should be given access to the processor.
• I/O or processor bound. If a processor bound job is given the main access to the processor it could prevent the I/O devices being serviced efficiently.
• Type of job. Batch processing, on-line and real-time jobs all require different response times.
• Resource requirements. The amount of time needed to complete the job, the memory required, I/O and processor time.
• Resources used so far. The amount of processor time used so far, how much I/O used so far.
• Waiting time. The time the job has been waiting to use the system.
In order to understand how scheduling is accomplished it is important to realise that any job may be in one, and only one, of three states. A job may be ready to start, running on the system or blocked because it is waiting for a peripheral, for example. Fig. 3.1.c.3 shows how jobs may be moved from one state to another. Note that a job can only enter the running state from the ready state. The ready and blocked states are queues that may hold several jobs. On a standard single processor computer only one job can be in the running state. Also, all jobs entering the system normally enter via the ready state and (normally) only leave the system from the running state.
... or complimentary fares. Rewarded for a good job with extra time off as well as trips and stays at ... with the failure. This business is transitional during this time. Many travel-related businesses have failed as a ... big part, long hours with a lot of over time and interpreted travel plans. Most of this work ... the job is very up to date and fast pace. There is rarely time to fool around or take time off ...
When entering the system a job is placed in the ready queue by the High Level Scheduler (HLS).
The HLS makes sure that the system is not over loaded.
Sometimes it is necessary to swap jobs between the main memory and backing store (see Memory Management in Section 3.1.d).
This is done by the Medium Level Scheduler (MLS).
Moving jobs in and out of the ready state is done by the Low Level Scheduler (LLS).
The LLS decides the order in which jobs are to be placed in the running state. There are many policies that may be used to do scheduling, but they can all be placed in one of two classes. These are pre-emptive and non-pre-emptive policies.
A pre-emptive scheme allows the LLS to remove a job from the running state so that another job can be placed in the running state. In a non-pre-emptive scheme each job runs until it no longer requires the processor. This may be because it has finished or because it needs an I/O device.
Some common scheduling policies are
• First Come First Served (FCFS)
• Shortest Job First (SJF)
• Round Robin (RR)
• Shortest Remaining Time (SRT)
• Multi-level Feedback Queues (MFQ)
and there are many more.
o simply means that the first job to enter the ready queue is the first to enter the running state. This favours long jobs.
o simply means sort jobs in the ready queue in ascending order of times expected to be needed by each job. New jobs are added to the queue in such a way as to preserve this order.
o this gives each job a maximum length of processor time (called a time slice) after which the job is put at the back of the ready queue and the job at the front of the queue is given use of the processor. If a job is completed before the maximum time is up it leaves the system.
... else. I consider myself to have three full time jobs. All of my jobs are equally important to me. Yes I lead ... one. I have a full-time job, attend school full-time, and I am a full-time parent to four kids. My ... breakfast we all take our turns in the bathroom getting ready for the busy day ahead of us. My daughter ... to wake up my children so they can get ready for school. As we all know breakfast is the ...
o the ready queue is sorted on the amount of expected time still required by a job. This scheme favours short jobs even more than SJF. Also there is a danger of long jobs being prevented from running.
o involves several queues of different priorities with jobs migrating downwards.
There are other ways of allocating priorities. Safety critical jobs will be given very high priority, on-line and real time applications will also have to have high priorities. For example, a computer monitoring the temperature and pressure in a chemical process whilst analysing results of readings taken over a period of time must give the high priority to the control program. If the temperature or pressure goes out of a pre-defined range, the control program must take over immediately. Similarly, if a bank’s computer is printing bank statements over night and someone wishes to use a cash point, the cash point job must take priority. This scheme is shown in Fig. 3.1.c.4; this shows that queues are needed for jobs with the same priority.