






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Practice Questions. November 2, 2021. TCSS422: Operating Systems [Fall 2021]. School of Engineering and Technology, University of Washington - Tacoma.
Typology: Exams
1 / 12
This page cannot be seen from the preview
Don't miss anything!







November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma
TCSS 422: OPERATING SYSTEMS Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 12 Quiz 1 (Due Tue Nov 2 ) – Quiz 2 (Due Thur Nov 4 ) Chapter 28: Locks: RISC atomic lock instructions Chapter 29: Lock Based Data Structures ▪ Approximate Counter (Sloppy Counter) ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^2
Daily Feedback Quiz in Canvas – Available Af ter Each Class Extra credit available for completing sur veys ON TIME Tuesday sur veys: due by ~ Wed @ 11:59p Thur sday sur veys: due ~ Mon @ 11:59p November 2, 2021 TCSS422: Computer Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^3
November 2, 2021 TCSS422: Computer Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10. 4 Please classify your per spective on material covered in today’s class (2 8 respondents): 1 - mostly review, 5-equal new/review, 10-mostly new Average – 6.50 ( - previous 6.66) Please rate the pace of today’s class: 1 - slow, 5-just right, 10-fast Average – 5.48 ( no change - previous 5.48) November 2, 2021 TCSS422: Computer Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^5
S ample problem #4 f rom TCSS 422 C PU S cheduler E xamples Issue with timing graph found New solution posted.. November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^6
November 2, 2021 (^) L10. 7 Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 12 Quiz 1 (Due Tue Nov 2 ) – Quiz 2 (Due Thur Nov 4 ) Chapter 28 : Locks: RISC atomic lock instructions Chapter 29: Lock Based Data Structures ▪ Approximate Counter (Sloppy Counter) ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^8
Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 1 2 Quiz 1 (Due Tue Nov 2 ) – Quiz 2 (Due Thur Nov 4 ) Chapter 28 : Locks: RISC atomic lock instructions
▪ Approximate Counter (Sloppy Counter) ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^9
Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 12 Quiz 1 (Due Tue Nov 2 ) – Quiz 2 (Due Thur Nov 4 ) Chapter 28 : Locks: RISC atomic lock instructions
▪ Approximate Counter (Sloppy Counter) ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^10
Active reading on Chapter 9 – Proportional Share Schedulers Posted in Canvas Due Tuesday Nov 2nd^ at 11:59pm Grace period til Thur sday Nov 4th^ at 11:59 ** AM ** Late submissions til Saturday Nov 6th^ at 11:59pm Link:
TCSS422_s2021_quiz_1.pdf November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10.^11
Due Thursday Nov 4 @ 11:59p Provides CPU scheduling practice problems ▪ FIFO, SJF, STCF, RR, MLFQ (Ch. 7 & 8) Unlimited attempts allowed Multiple choice and fill-in the blank Quiz automatically scored by Canvas ▪ Please report any grading problems November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10.^12
CHAPTER 29 – LOCK BASED DATA STRUCTURES November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10. 19
November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^20
November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^21
Synchronization wear y --- not thread safe Add lock to the counter Require lock to change data November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^22
Decrease counter Get value November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^23
Concurrent counter is considered a “precise counter” iMac: four core Intel 2.7 GHz i5 CPU Each thread increments counter 1,000,000 times November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^24
Achieve (N) per formance gain with (N) additional resources Throughput: Transactions per second ( tps) 1 core N = 100 tps 10 cores (x10) N = 1000 tps (x10) I s pa rallel counting with a shared counter a n em barrassingly pa rallel problem? November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^25
Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 12 Quiz 1 (Due Tue Nov 2 ) – Quiz 2 (Due Thur Nov 4 ) Chapter 28 : Locks: RISC atomic lock instructions Chapter 29: Lock Based Data Structures ▪ Approximate Counter (Sloppy Counter) ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^26
Provides single logical shared counter ▪ Implemented using local counters for each ~CPU core ▪ 4 CPU cores = 4 local counters & 1 global counter ▪ Local counters are synchronized via local locks ▪ Global counter is updated periodically ▪ Global counter has lock to protect global counter value ▪ Update threshold (S ) – referred to as sloppiness threshold: How often to push local values to global counter ▪ Small ( S ): more updates, more overhead ▪ Large ( S ): fewer updates, more performant, less synchronized Why this implementation?
November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^27
Idea of the Approximate Counter is to RELAX the synchronization requirement for counting
▪ Synchronization occurs only every so often: e.g. every 1000 counts Relaxing the synchronization requirement drastically reduces locking API overhead by trading - off split-second accuracy of the counter Approximate counter: trade-off accuracy for speed ▪ It’s approximate because it’s not so accurate (until the end) November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^28
Update threshold ( S ) = 5 Synchronized across four CPU cores Threads update local CPU counter s November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^29
Consider 4 threads increment a counter 1000000 times each Low S → What is the consequence? High S → What is the consequence? November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^30
▪ Lock everything inside Insert() and Lookup() ▪ If malloc() fails lock must be released ▪ Research has shown “ exception-based control flow ” to be error prone ▪ 40% of Linux OS bugs occur in rarely taken code paths ▪ Unlocking in an exception handler is considered a poor coding practice ▪ There is nothing specifically wrong with this example however Second Implementation … November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^37
Init and Inser t November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^38
Lookup November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^39
Using a single lock for entire list is not ver y per formant User s must “wait” in line for a single lock to access/modify any item Hand-over-hand-locking (lock coupling) ▪ Introduce a lock for each node of a list ▪ Traversal involves handing over previous node’s lock, acquiring the next node’s lock… ▪ Improves lock granularity ▪ Degrades traversal performance Consider hybrid approach ▪ Fewer locks, but more than 1 ▪ Best lock-to-node distribution? November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^40
Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 12
Chapter 28 : Locks: RISC atomic lock instructions Chapter 29: Lock Based Data Structures ▪ Sloppy Counter ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^41
Improvement beyond a single master lock for a queue (FIFO) Two locks: ▪ One for the head of the queue ▪ One for the tail Synchronize enqueue and dequeue operations Add a dummy node ▪ Allocated in the queue initialization routine ▪ Supports separation of head and tail operations Items can be added and removed by separate threads at the same time November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^42
Remove from queue November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^43
Add to queue November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^44
Questions from 10 / 28 Assignment 0 Update Assignment 1 – Nov 12 Quiz 1 (Due Tue Nov 2 ) – Quiz 2 (Due Thur Nov 4 ) Chapter 28 : Locks: RISC atomic lock instructions
▪ Sloppy Counter ▪ Concurrent Structures: Linked List, Queue, Hash Table 2 nd^ hour: Midterm Review ▪ Practice Questions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^45
▪ Bucket is implemented using a concurrent linked list ▪ One lock per hash (bucket)
November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^46
Four threads – 10,000 to 50,000 inser ts ▪ iMac with four-core Intel 2.7 GHz CPU November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^47
The simple concurrent hash table scales magnificently. November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^48
Operation of CPU schedulers can be visualized with timing graphs. The graph below depicts a FIFO scheduler where three jobs arrive in the sequence A, B, C, where job A runs for 10 time slices, job B for 5 time slices, and job C for 10 time slices. | FIFO |AAAAAAAAAABBBBBCCCCCCCCC |___________________________________ 0 10 15 25 November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^55
Draw a scheduling graph for the SJF scheduler without preemption for the following jobs. Draw ver tical lines for key events and be sure to label the X - axis times as in the example. Job Arrival Time Job Length A T=0 25 B T=5 10 C T=10 15 | S J F || | | _ __ __ __ _ __ __ __ __ _ __ __ __ __ _ __ __ __ __ _ __ __ __ __ __ _ __ __ __ _ __ __ __ _ 0 November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^56
What is the response time (RT) and turnaround time (TT) for jobs A, B, and C? R T J o b A : __ _ _ __ _ _ _ __ _ _ __ _ T T J o b A : __ _ _ __ _ _ _ __ _ _ __ _ R T J o b B : __ _ _ __ _ _ _ __ _ _ __ _ T T J o b B : __ _ _ __ _ _ _ __ _ _ __ _ R T J o b C : __ _ _ __ _ _ _ __ _ _ __ _ T T J o b C : __ _ _ __ _ _ _ __ _ _ __ _ What is the average response time for all jobs? _____________ What is the average turnaround time for all jobs? ___________ November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^57
Draw a scheduling graph for the STCF scheduler with preemption for the following jobs. Draw ver tical lines for key events and be sure to label the X - axis times as in the example. Job Arrival Time Job Length A T=0 25 B T=5 10 C T=10 15 | | C P U | | | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 0 November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^58
What is the response time (RT) and turnaround time (TT) for jobs A, B, and C? R T J o b A : __ _ _ __ _ _ _ __ _ _ __ _ T T J o b A : __ _ _ __ _ _ _ __ _ _ __ _ R T J o b B : __ _ _ __ _ _ _ __ _ _ __ _ T T J o b B : __ _ _ __ _ _ _ __ _ _ __ _ R T J o b C : __ _ _ __ _ _ _ __ _ _ __ _ T T J o b C : __ _ _ __ _ _ _ __ _ _ __ _ What is the average response time for all jobs? ___________ What is the average turnaround time for all jobs? __________ November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^59
In a per fect - multi-tasking operating system, ever y process of the same priority will always receive exactly 1/n th^ of the available CPU time. Impor tant CPU improvements for multi - tasking include: (1) fast context switching to enable jobs to be swapped in - and-out of the CPU ver y quickly, and (2) the use of a timer interrupt to preempt running jobs without the user voluntarily yielding the CPU. These innovations have enabled major improvements towards achieving a coveted “Per fect Multi - Tasking System”. List and describe two challenges that remain complicating the full realization of a Per fect Multi - Tasking Operating System. In other words, what makes it ver y dif ficult for all jobs (for example, 10 jobs) of the same priority to receive E XACTLY the same runtime on the CPU? Your description must explain why the challenge is a problem for achieving per fect multi - tasking. November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^62
Show a scheduling graph for a Round - Robin (RR) scheduler with job preemption where newly arriving jobs will immediately run. Assume a time slice of 3 timer units. sure to label the X-axis times as in the example. Draw ver tical lines for key events and be Job Arrival Time Job Length A T=0 25 B T=5 10 C T=10 15 | R R || | | ___ __ ___ ___ __ ___ ___ ___ __ ___ ___ __ ___ ___ __ ___ __ ___ ___ __ __ 0 November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^63
Using the graph, from time t=10 until all jobs complete at t=50, evaluate Jain’s Fairness Index: Jain’s fairness index is expressed as: Where n is the number of jobs, and x (^) i is the time share of each process Jain’s fairness index=1 for best case fairness, and 1/n for wor st case fairness. For the time window from t=10 to t=50, what percentage of the CPU time is allocated to each of the jobs A , B, and C? Job A: ________ Job B: ________ Job C: ________ With these values, calculate Jain’s fairness index from t=10 to t=50. November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^64
Below is a tradeoff space graph similar to those we’ve shown in class. Based on the sloppy counter threshold (S), add numbers on the lef t or r ight side of the graph for each of the following tradeof fs:
Review the bonus lecture for scheduling examples including several Multi-level-feedback-queue problems (MLFQ)
November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^66