








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma
TCSS 422: OPERATING SYSTEMS
RR scheduler
MLFQ Scheduler Job Starvation Gaming the Scheduler Examples
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Daily Feedback Quiz in Canvas – Available After Each Class Extra credit available for completing surveys ON TI ME Tuesday surveys: due by ~ Wed @ 11:59p Thursday surveys: due ~ Mon @ 11:59p April 15, 2021 TCSS422: Computer Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Computer Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6. Please classify your perspective on material covered in today’s class (52 respondents): 1-mostly review, 5-equal new/review, 10-mostly new Average – 7.27 ( - previous 6 .91) Please rate the pace of today’s class: 1-slow, 5-just right, 10-fast Average – 5 .52 ( - previous 5 .65) April 15, 2021 TCSS422: Computer Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
What is the purpose of calculating tu rnaround time and response time? Calculating these metrics helps us compare different CPU scheduling algorithms relative to scheduling a specific set of jobs The idea is to find the best scheduling algorithm for a set of jobs It is hard to find a scheduling algorithm that is good for ALL jobs Do p rograms usually ou tput a s or t of "p rojected time to completion" to facilitate easier s or ting for fairness? No, often little information is available to suggest program runtime Fairness is frequently evaluated after-the-fact The percentage execution time may be given: A=52% B=32% C=16% Or we must calculate the % time: A=10m 24s B=6m 24s C=3m 12s Is it common p ractice to break down different measures of fairness for resource allocation when designing pr ograms? No. used to share computing resources (CPU, disk, network) We calculate fairness to compare operating system algorithms April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
No, the share of the resource is the Xi values we use to calculate the Jain’s fairness index score. Perfect fairness always equals 1. This is when a resource is shared equally among a set of processes/users Low values are always bad. If the number of processes is small, the value may not be that small
Consider JFI for A=52% B=32% C=16% April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
If SJF (Shor test job fir st) scheduler is not realistic, why is it s till being used? The textbook introduces some “pedagogical schedulers” FIFO and Round-robin are actually legitimate schedulers SJF and STCF require knowing how long a job will run in advance and this information is often not known Each successive scheduler introduces new features and capabilities We are building towards schedulers full-featured schedulers Linux, for example, does not predict job runtime, but it does TRACK cumulative job runtime in making future scheduling decisions How would the implementation of a s cheduler look? Both at a higher and lower level. Round-robin/FIFO can be simple. Involve a queue and job pointer April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
fopen() and other functions like it are provided largely out of convenience for developers Specialized wrappers such as fopen() abstract additional functionality to make it more easily accessible for programmers
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Can we go over trap tables in a little more detail? TRAP TABLE: The x86 processor uses a table known as the interrupt descriptor table (IDT) to determine how to transfer control when a trap occurs. The x86 allows up to 256 different interrupt or exception entry points into the kernel, each with a different interrupt vector. TRAP HANDLERS: Trap handlers are OS kernel functions that are pointed to by the trap table. These are “event handlers” that respond to various traps. April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
RR scheduler
MLFQ Scheduler Job Starvation Gaming the Scheduler Examples
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
RR scheduler
MLFQ Scheduler Job Starvation Gaming the Scheduler Examples
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Cpu utilization = 100/100=100% April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
A B C 0 400 500 700 Example: April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.23 April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
B C A 0 100 300 700 Example: April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6. April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
RR scheduler
MLFQ Scheduler Job Starvation Gaming the Scheduler Examples
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
CHAPTER 8 – MULTI-LEVEL FEEDBACK QUEUE (MLFQ) SCHEDULER April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
RR scheduler
MLFQ Scheduler Job Starvation Gaming the Scheduler Examples
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
RR scheduler
MLFQ Scheduler Job Starvation Gaming the Scheduler Examples
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Priority becomes stuck
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Starvation
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
With
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Consider 3 queues: Q2 – HIGH PRIORIT Y – Time Quantum 10ms Q1 – MEDIUM PRIORIT Y – Time Quantum 20 ms Q0 – LOW PRIORIT Y – Time Quantum 40 ms Job A: 200ms no I/O Job B: 5ms then I/O Job C: 5ms then I/O Q2 fills up, starves Q1 & Q A makes no progress April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Starvation Improved time accounting: Track total job execution time in the queue Each job receives a fixed time allotment When allotment is exhausted, job priority is lowered April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
How many queues? What is a good time slice? How often should we “Boost” priority of jobs? What about different time slices to different queues? April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
CPU, disk I/O, memory April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Picks the winning ticket
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
12 //int counter: counter used= 0 ; to track if we’ve found the winner yet (^34) // winner: use some call to a random number generator to 56 //int get winner a value, = getrandom( between 0 0 and, totaltickets); the total # of tickets (^78) // current: use this to walk through the list of jobs 910 node_t *current = head; 1112 //while loop (current) until the { sum of ticket values is > the winner 1314 counterif (counter = counter > winner) + current->tickets; (^1516) current = breakcurrent->next;; // found the winner 1718 }// ’current’ is the winner: schedule it...
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Job A has 75 tickets: 0 - 74 Job B has 25 tickets: 75 – 99
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Scheduled job:
Equality of distribution (fairness) requires a lot of flips! April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Similarly, Lottery scheduling requires lots of “rounds” to achieve fairness. April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
With two jobs Each with the same number of tickets (t=100) When the job length is not very long, average unfairness can be quite severe.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
A stride value describes the counter pace when the job should give up the CPU Stride value is inverse in proportion to the job’s number of tickets (more tickets = smaller stride)
Job A has 100 tickets Astride = 10000/100 = 100 stride Job B has 50 tickets Bstride = 10000/50 = 200 stride Job C has 250 tickets Cstride = 10000/250 = 40 stride
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Every thread/process has a scheduling class (policy): Normal classes: SCHED_OTHER (TS), SCHED_IDLE, SCHED_BATCH TS = Time Sharing Real-time classes: SCHED_FIFO (FF), SCHED_RR (RR) How to show scheduling class and priority:
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
Linux ≥ 2.6.23: Completely Fair Scheduler (CFS) Linux < 2.6.23: O(1) scheduler Linux maintains simple counter (vruntime) to track how long each thread/process has run CFS picks process with lowest vruntime to run next CFS adjusts timeslice based on # of proc waiting for the CPU Kernel parameters that specify CFS behavior: April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
$ sudo sysctl kernel.sched_latency_ns kernel.sched_latency_ns = 24000000 $ sudo sysctl kernel.sched_min_granularity_ns kernel.sched_min_granularity_ns = 3000000 $ sudo sysctl kernel.sched_wakeup_granularity_ns kernel.sched_wakeup_granularity_ns = 4000000 Sched_min_granularity_ns (3ms) Time slice for a process: busy system (w/ full runqueue) If system has idle capacity, time slice exceed the min as long as dif ference in vruntime between running process and process with lowest vruntime is less than sched_wakeup_granularity_ns (4ms) Scheduling time period is: total cycle time for iterating through a set of processes where each is allowed to run (like round robin) Example: sched_latency_ns (24ms) if (proc in runqueue < sched_latency_ns/sched_min_granularity) or sched_min_granularity * number of processes in runqueue R e f : h t t p s : / / w w w. s y s t u t o r i a l s. c o m / s c h e d _ m i n _ g r a n u l a r i t y _ n s - s c h e d _ l a t e n c y _ n s - c f s - a f f e c t - t i m e s l i c e - p r o c e s s e s / April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
HIGH sched_min_granularity_ns (timeslice) sched_latency_ns sched_wakeup_granularity_ns reduced context switching less overhead poor near-term fairness LOW sched_min_granularity_ns (timeslice) sched_latency_ns sched_wakreup_granularity_ns increased context switching more overhead better near-term fairness April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
~O(log N) for N nodes
Influences job’s position in rb-tree April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
CFS tracks cumulative job run time in vruntime variable The task on a given runqueue with the lowest vruntime is scheduled next struct sched_entity contains vruntime parameter Describes process execution time in nanoseconds Value is not pure runtime, is weighted based on job priority Perfect scheduler achieve equal vruntime for all processes of same priority Sleeping jobs: upon return reset vruntime to lowest value in system Jobs with frequent short sleep SUFFER !!
April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.
More information: Man page: “man sched” : Describes Linux scheduling API http://manpages.ubuntu.com/manpages/bionic/man7/sched.7.html https://www.kernel.org/doc/Documentation/scheduler/sched- design-CFS.txt https://en.wikipedia.org/wiki/Completely_Fair_Scheduler See paper: The Linux Scheduler – a Decade of Wasted Cores http://www.ece.ubc.ca/~sasha/papers/eurosys16-final29.pdf April 15, 2021 TCSS422: Operating Systems [Spring 2021] School of Engineering and Technology, University of Washington - Tacoma L6.