Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced OS Concepts (For OCR)

Similar presentations


Presentation on theme: "Advanced OS Concepts (For OCR)"— Presentation transcript:

1 Advanced OS Concepts (For OCR)
Nick Sims

2 Memory Management - Scheduling
OS schedules the jobs in sequence Making best use of the processor Important that the input / output phrase must not delay the processor This could be a problem if the input output devices are slow… This can be overcome by using Simultaneous Peripheral Operations On-Line (or spooling)

3 Memory Management - Scheduling
Spooling is to store all input and output on a high-speed device such as a disk Input Spool Output spool Input device Output device Read Process Application Program Write process

4 Memory Management - Scheduling
Another problem is that programs may not be loaded into the same memory locations each time they have been loaded i.e. suppose three programs were loaded in the order of A, B, and C on one occasion And again the order C, A, and B on another occasion The processor needs to know where all the data and instructions are stored So moving data / instructions around can have enormous implications

5 Memory Management - Loader
The loader remembers exactly where everything is every time it is loaded The loader remembers bits of programs that have moved to different places how to stay in touch with each other

6 The Process Concept This is important in multi-programming operating systems What type of an operating system is this? This is an O.S. that allows a number of programs to appear to be running simultaneously on one computer Definition: a process is a program actually running on the CPU, even though it might be waiting for I/O at a particular moment

7 The Process Concept Example: remember there could be only one CPU
a Pascal Compiler may be executed by several people simultaneously on a network There will only be one copy in memory Different parts of it will be used by several different people to compile their programs They will share the same code Each instance of the program running will be a process, with separate data areas maintained for each execution A program working this way is said to be re-entrant

8 Memory Management - The Loader
A further problem is where: two or more users use the same program at the same time Waste of time if two copies are loaded into main memory So user X’s program and user’s Y’s program are stored in main memory along with a single copy of the program OS User X’s program and data User Y’s program and data Compiler Free Re-Entrant Two users can use the program in turn and will want to use different parts of the program. There will be two different sets of data for the compiler. Two sets of data must be kept separate.

9 Memory Management - Interrupts
Interrupts are used to gain processor time Start This process is fine as long as the program being run maintains control of the processor! Fetch Function Execute Instruction YES Any more instructions? NO End

10 Memory Management - Loader
If a user has used all the time allocated to the use of the processor, it will be necessary to stop that program running in order to be fair to all users This is managed through a scheduling algorithm Interrupts instigates this change These are messages sent to the processor by some external entity I/O Interrupt – generated by I/O device to signal a job to complete or an error occurred Timer Interrupt – generated by an internal clock indicating the processor must attend to time critical activities Hardware error – power failure which indicates that the OS must be close down safely as possible Program Interrupt – Generated due to an error in a program such as violation of memory use (trying to use part of the memory reserved for the operating system) or an attempt to execute an invalid instruction (division by zero)

11 Memory Management - Interrupts
Start After 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. New instructions are obeyed and the contents of the registers are stored in a stack… Fetch Function Execute Instruction Any more instructions? End YES NO Is there an interrupt? Service Interrupt

12 Memory Management - Interrupts
If an interrupt interrupts another interrupt, then a queue is used, only return to the original program when the queue is empty. The position of an individual interrupt in the queue is determined by their importance to the user, to the system and to the job itself. Each job is given a priority and the further along the queue it is stored. Start Fetch Function Any more instructions? Execute Instruction Is there an interrupt? YES YES Service Interrupt NO End

13 The purpose of scheduling, job queues, and priorities
OS has to arrange jobs that need to be done in the appropriate order The order is chosen for the maximum use made of the processor; another order may make one job more important than the other The OS makes use of priorities

14 The purpose of scheduling, job queues, and priorities
The processor is required by program ‘A’ (wage slips) And the processor is required for program ‘B’ (which analyses the annual, world-wide sales of the company which has a turnover of a million pounds) Program ‘A’ makes very little use of the processor – jobs are concerned about input and output (I/O bound jobs) Program ‘B’ makes a great deal of the processor, only needing to collect one set of data from the drive and producing one lot of printout at the end (job is processor bound)

15 The purpose of scheduling, job queues, and priorities
Program B has priority over a program ‘A’ for use of the processor, it could be a long time before program ‘A’ can print, because ‘B’s’ processing will need to be done before ‘A’ gets a look in It would be more fair to let ‘A’ do a bit or processing and then use the printer, because printing takes a longer time, Then whilst the printing is carried out, B is allowed to use the processor

16 The purpose of scheduling, job queues, and priorities
The objectives of scheduling are to: Maximise the use of the whole of the computing system Be fair to all users Provide a reasonable response time to all users, whether they are online users Prevent the system failing if it is becoming overloaded Ensure that the system is consistent by always giving similar response times to similar activities from day-to-day

17 Scheduling To achieve these objectives some criteria are needed in order to determine the order in which jobs are executed

18 Scheduling The OS needs to schedule all of the tasks that it is required to carry out The CPU can only carry out one instruction at a time, so the instructions need to be sent to the processor in the most efficient way in order to get all the tasks done. Priority scheduling: give each task a priority and do them in order of importance. Type of job – batch processing and real-time jobs require different response times (Job Control Language (JCL) - a language that allows the user to program the sequence in which tasks will be carried out – usually used with a batch OS. Resource requirements – the amount of time required to complete the job, the memory required, I/O and processor time (Time slicing: give each job a piece of processor time on a round-robin basis) 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.

19 Time slicing Each task is given a small slice of processor time.
Part of the task will be completed in that time slice and then the processor moves on to the next task and so on. After a period of time, a task will have had enough time slices to be complete so no more time slices need allocating. At any one time the processor will be handling part of one of the tasks that need to be complete. The more tasks it is asked to do, the longer it will take to complete each task. The OS can allocate different time-slices to different tasks.

20 Threads Each process can have more than one thread.
Each thread has a scheduled state (runnable, running and suspended) All threads share most of their environment Same virtual address space for instructions and global variables, but they have their own local variables, program counter, registers and stack pointer. Each thread has it’s own control block (TCB). The PCB holds references to one or more TCB. This means less memory is used and it requires less work to create or delete threads than separate processes because threads share virtual address space

21 Threads A thread is a path of execution within a process
Operating systems that support multi-threading enable the programmers to design programs whose threaded parts can execute concurrently Used for writing client-server applications – the programmer must design the program in such a way that all threads can run concurrently without interfering with each other


Download ppt "Advanced OS Concepts (For OCR)"

Similar presentations


Ads by Google