1 / 34

The Functions of Operating Systems

The Functions of Operating Systems . Scheduling (multi-programming). Learning Objectives. Define and explain the purpose of scheduling, job queues, priorities and how they are used to manage job throughput. Multi-Programming.

parry
Download Presentation

The Functions of Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Functions of Operating Systems Scheduling (multi-programming)

  2. Learning Objectives • Define and explain the purpose of scheduling, job queues, priorities and how they are used to manage job throughput.

  3. Multi-Programming • Predecessor to multi-tasking / multi-user, without “Round-Robin”. • See “Multi-Tasking & Multi-User / Access Presentation” from AS Computing. • Several different programs are loaded in the computer memory, and the first one begins to run. • When the first program reaches an instruction waiting for a peripheral (e.g. a printer), the context of the program is stored away, and the second program in memory is given a chance to run. • The process continues until all programs finish running.

  4. Appropriate order of tasks • One of the tasks of the OS is to arrange the jobs that need to be done into an appropriate order.

  5. 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.

  6. Input / Output (I/O) Vs Processor Bound Jobs • Input / Output (I/O) Bound Jobs: • Jobs that require relatively little processing but do need to use the peripheral devices substantially. • E.g. Printing wage slips for the employees of a large company. • Processor Bound Jobs: • Jobs that require a large amount of processor time and very little use of the various peripheral devices. • E.g. Analysing the annual, world-wide sales of the company which has a turnover of many millions of pounds. • As this is decided before running it is a non pre-emptivepolicy.

  7. Priority? • If a processor bound job has priority over a I/O bound job for use of the processor, it could be a long time before the I/O job is executed. • E.g. The pay slips can be printed.

  8. Priority? • If a I/O bound job has priority over a processor bound job for use of the processor, I/O bound job can still run in a reasonable time and much better throughput is achieved.

  9. The three states of a job/process: • Ready/Runnable to start. • Running on the system. • Blocked because it is waiting for a peripheral

  10. Note: • Jobs / Processes are synonyms (the same). • A job can only enter the running state from the ready state. • The ready/runnable 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. • All jobs entering the system normally enter via the ready/runnable state and (normally) only leave the system from the running state.

  11. High Level Scheduler (HLS) / Long Term Scheduler / Admissions Scheduler • Deals with the Ready/Runnable state by deciding which process/job should be loaded next in the ready queue held in the main memory. • Makes sure that the system is not over loaded as it will only consider processes/jobs if space in main memory is or becomes available. • When deciding on which process to load next it considers the following attributes or priorities: • Estimated run time. • Time to deadline. • Estimated memory requirements. • Resources required. • User priority.

  12. Low Level Scheduler (LLS) / Short Term Scheduler • Deals with Running state by moving jobs between the ready and running states or removing them from the system once they are completed. • Decides the order in which jobs are to be placed in the running state.

  13. Medium Level Scheduler (MLS) / Medium Term Scheduler • Deals with the Blocked state by swapping jobs between the ready state in the main memory and the backing store.

  14. Differences between high, low & medium level scheduling • Night club analogy: • The bouncer is high level scheduling. • He determines who gets into the club, i.e., which tasks or requests are accepted by the system. • The hostess is low level scheduling. • She seats each person based on priority and space. • If a VIP (i.e., high priority task) enters the club (i.e., computer system), scheduling places that VIP to the front of the line, and everyone that is deemed a lower priority must wait until the VIP is seated and served. • Medium level scheduling. • If someone gets into the club, but it is full, they may be asked to wait in another room until a table opens up. • http://smallbusiness.chron.com/low-level-high-level-scheduling-26299.html

  15. Scheduling Summary http://www.theteacher.info/websites/ocr/WebPages/F453_Advanced/Scheduling/Scheduling.html

  16. Pre-Emptive & Non-Pre-Emptive • Pre-Emptive Scheme / Policy: • Allows the LLS to remove a job when not complete from the running state so that another job can be placed in the running state. • So has control over what is in running state and means the interrupt queue is checked after each cycle. • Non-Pre-Emptive Policy: • Each job runs until it no longer requires the processor. • This may be because it has finished or because it needs an Input / Output device (see I/O Bound Jobs later). • Simply follows the queue set before a job is started and is only re-arranged (if at all – see First Come First Served later) after a job is complete. • Policy – a method of arranging the queue or stopping a job. • Scheme – when the Round Robin policy (pre-emptive) is combined with another. • See later.

  17. Importance of job / Type of job: • Safety critical jobs will be given very high priority, on-line and real time applications will also have to have high priorities. • E.g. • 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. • 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. • Also remember I/O bound jobs will also get priority as stated earlier. • Depending on if the queue is checked after each cycle or not this can be a Pre-Emptivepolicy or a Non Pre-Emptivepolicy.

  18. First Come First Served (FCFS) / FIFO / LILO • First job to enter ready queue is first to enter running state. • Favours long jobs. • There is no point in rechecking the queue during a job as the queue is FCFS so this is a non pre-emptivepolicy.

  19. Shortest Job First (SJF) / Shortest Estimated Run Time • Sorts jobs in ready queue in ascending order of time expected to be needed by each job. • New jobs are added in such a way so as to preserve this order. • As the queue is arranged before a job is started and only checked again once a job is finished it is a Non-Pre-Emptivepolicy. • If this was not the case and job is recalculated after each cycle then it would become Shortest Remaining Time (see later). Make sure you describe policies when you list them, do not just name them; particularly this policy, “Shortest job first”, which should be described as “Estimated completion time” as otherwise examiners will complain that there is no indication of what is “shortest”.

  20. Round Robin (RR) • Each job is given a set amount of processor/quantum time. • At the end of the time available for a job, it is interrupted. • The operating system inspects the queue of jobs still to be processed. • If it is not empty allocates the next amount of processor time to the job first in the queue. • The previous job goes to the end of the queue. • If a job is completed before the maximum time is up it leaves the system. • This policy has to be used in conjunction with another policy as it does not deal with the initial arrangement of the queue. • However, as it interrupts jobs whether they are finished or not, it forms a Pre-Emptive scheme performed when combined with another policy.

  21. Shortest Remaining Time (SRT) • The ready queue is sorted on the amount of expected time still required by a job. • Favours short jobs even more than SJF. • There is a danger of long jobs being prevented from running. • To be meaningful it must be re-calculated meaning that jobs must be interrupted without being complete so is a pre-emptive policy. • This would be done either after each cycle or processor/quantum time if combined with RR (so forming a scheme). • Note if SRT were not recalculated it would be affectively SJF.

  22. Multi-level Feedback Queues (MFQ) • Several queues of different priorities with jobs migrating downwards. • Multiple FCFS / FIFO / LILO policy schedule queues are used and the operation is as follows:

  23. A new job is positioned at the end of the top-level FIFO queue. Time up Time up Time up Jobs circulate in round robin fashion until they complete and leave the system.

  24. Multi-Level Feedback Queues • A new job is positioned at the end of the top-level FCFS queue. • At some stage the job reaches the head of the queue and is assigned to the CPU. • If the job is completed it leaves the system. • If the job uses all the quantum time, it is pre-empted and positioned at the end of the next lower level queue. • A job is given just one chance to complete at a given queue level before it is forced down to a lower level queue. • If the job is an I/O job and is blocked it leaves the queuing network, and when the process is unblocked it is 'promoted' one level, and placed at the end of the next-highest queue. • This allows I/O bound processes to be favoured by the scheduler and allows processes to 'escape' the base level queue. • This will continue until the process completes or it reaches the base level queue where jobs circulate in round robin fashion until they complete and leave the system.

  25. Multi-Level Feedback Queues • Give preference to short jobs. • Give preference to I/O bound processes. • Quickly establish the nature of a process and schedule the process accordingly. • As uses RR and FCFS it is a Pre-Emptive Scheme(see earlier).

  26. Note • Pre-emptive policies can only be performed by the LLS as only the LLS can remove jobs from the running state (the HLS only places jobs in the ready state). • Non Pre-emptive methods can be performed by both the HLS and the LLS (as both the HLS and LLS can place jobs in the ready state, the difference being that the HLS does this from outside the system – secondary storage - and the LLS from the running state). • To avoid problems when answering exam questions make sure you describe policies when you list them; do not just name them. If you do not then you may not be given the marks. • Particularly the policy “Shortest job first”, which should be described as “Estimated completion time” as there must be some indication of what is “shortest” and could be confused with “Shortest remaining time” which is pre-emptive and can only be performed by the LLS. • Also “Round-Robin” is not considered to be a method of allocating priority, it is only a scheduling policy.

  27. Summary List Non Pre-emptive which can be performed by both the HLS and the LLS: • First Come First (FCFS) • Time to deadline. • Amount of peripheral time / resources required. • Compares I/O jobs and asks “How much of a I/O job are you?”. • Estimated memory requirements. • Necessary response time / Time to deadline. • Compares real-time / on-line jobs and asks “How much of a real-time / on-line jobs are you?” or “OK, you are a real-time / on-line job but how quickly do I need to respond to you?” • User Priority • Shortest Job First (SJF) – Estimated run time. • Importance / Type of job. • Amount of time already waited. Pre-emptive policies which can be performed by only the LLS: • Round Robin (RR). • Not considered to be a “method of allocating priority”. • Shortest Remaining Time (SRT). • Amount of processor time already given. • Multi-Level Feedback (MLF). • Amount of processor time already given.

  28. Plenary • Describe the objectives of scheduling in a multi-user operating system.

  29. 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.

  30. Plenary • Describe some common scheduling policies.

  31. Common Scheduling Policies • First Come First Served (FCFS) • First job to enter ready queue is first to enter running state. • Favours long jobs. • Shortest Job First (SJF) • Sorts jobs in ready queue in ascending order of time expected to be needed by each job. • New jobs are added in such a way so as to preserve this order. • Round Robin (RR) • 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.

  32. Common Scheduling Policies • Shortest Remaining Time (SRT) • The ready queue is sorted on the amount of expected time still required by a job. • Favours short jobs even more than SJF. • There is a danger of long jobs being prevented from running. • Multi-level Feedback Queues (MFQ) • Several queues of different priorities with jobs migrating downwards.

  33. Plenary • State methods by which the priority of a job may be determined.

  34. List of all methods of allocating priorities: • First Come First (FCFS) • Amount of time already waited. • Shortest Job First (SJF) • Importance / Type of job • Safety critical jobs given higher priority. • I/O bound jobs given higher priority than Processor bound jobs. • Amount of peripheral time. • On-line and real time jobs given higher priority. • Necessary response time. • Round Robin (RR) • Shortest Remaining Time (SRT) • Amount of processor time already given. • Multi-Level Feedback (MLF)

More Related