Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Cloud Services Innovation Platform (CSIP), Exams of Operating Systems

Practice Questions. November 2, 2021. TCSS422: Operating Systems [Fall 2021]. School of Engineering and Technology, University of Washington - Tacoma.

Typology: Exams

2022/2023

Uploaded on 05/11/2023

faylin
faylin 🇺🇸

4.9

(8)

225 documents

1 / 12

Toggle sidebar

Often downloaded together


Related documents


Partial preview of the text

Download Cloud Services Innovation Platform (CSIP) and more Exams Operating Systems in PDF only on Docsity!

School of Engineering and Technology

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma

Lock-based data structures,

Midterm review

Wes J. Lloyd

School of Engineering and Technology

University of Washington - 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

OBJECTIVES – 11/

 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

ONLINE DAILY FEEDBACK SURVEY

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

MATERIAL / PACE

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

FEEDBACK

School of Engineering and Technology

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

OBJECTIVES – 11/

 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

 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.^9

OBJECTIVES – 11/

 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.^10

OBJECTIVES – 11/

 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:

 http://faculty.washington.edu/wlloyd/courses/tcss422/

TCSS422_s2021_quiz_1.pdf November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10.^11

QUIZ 1

 Quiz posted on Canvas

 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

QUIZ 2 - CPU SCHEDULING ALGORITHMS

School of Engineering and Technology

 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.^13

OBJECTIVES – 11/

November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10. 41  Cooperative atomic instructions used together to support synchronization on RISC systems  Instructions provided as opposed to: XCHG, CMPXCHG(8B,16B)  No support on x86 processors ▪ Supported by RISC: Alpha, PowerPC, ARM  Load-linked (LL) ▪ Loads value into register ▪ Same as typical load ▪ Used as a mechanism to track competition  Store-conditional (SC) ▪ Performs “mutually exclusive” store ▪ Allows only one thread to store value November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10.^15

TWO MORE “LOCK BUILDING”

CPU INSTRUCTIONS

 LL instruction loads pointer value ( ptr)  SC only stores if the load link pointer has not changed  Requires HW support

▪ C code is psuedo code

November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10.^16

LL/SC LOCK

 Two instruction lock November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10.^17

LL/SC LOCK - 2

 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.^18

OBJECTIVES – 11/

School of Engineering and Technology

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

 Adding locks to data structures make them

thread safe.

 Considerations:

▪ Correctness

▪ Performance

▪ Lock granularity

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^20

LOCK-BASED

CONCURRENT DATA STRUCTURES

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^21

COUNTER STRUCTURE W/O LOCK

 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

CONCURRENT COUNTER

 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 - 2

 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

CONCURRENT COUNTERS - PERFORMANCE

Precise counter scales poorly.

School of Engineering and Technology

 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

PERFECT SCALING

 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

OBJECTIVES – 11/

 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?

Why do we want counters local to each CPU Core?

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^27

APPROXIMATE (SLOPPY) COUNTER

 Idea of the Approximate Counter is to RELAX the synchronization requirement for counting

▪ Instead of synchronizing global count variable each time:

counter=counter+

▪ 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

APPROXIMATE COUNTER – MAIN POINTS

 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

APPROXIMATE COUNTER - 2

 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

THRESHOLD VALUE S

School of Engineering and Technology

 Example implementation – sloppybasic.c  Also with CPU af finity November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^31

APPROXIMATE COUNTER - EXAMPLE

November 2, 2021 TCSS422: Operating Systems [Fall 2021] School of Engineering and Technology, University of Washington - Tacoma L10. 23  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

▪ 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.^33

OBJECTIVES – 11/

 Simplification - only basic list operations shown  Structs and initialization: November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^34

CONCURRENT LINKED LIST - 1

 Inser t – adds item to list  Ever ything is critical! ▪ There are two unlocks November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^35

CONCURRENT LINKED LIST - 2

}  Lookup – checks list for existence of item with key  Once again ever ything is critical ▪ Note - there are also two unlocks November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^36

CONCURRENT LINKED LIST - 3

School of Engineering and Technology

 First Implementation:

▪ 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

CONCURRENT LINKED LIST

 Init and Inser t November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^38

CCL – SECOND IMPLEMENTATION

 Lookup November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^39

CCL – SECOND IMPLEMENTATION - 2

 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

CONCURRENT LINKED LIST PERFORMANCE

 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 ▪ 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

OBJECTIVES – 11/

 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

MICHAEL AND SCOTT CONCURRENT QUEUES

School of Engineering and Technology

 Remove from queue November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^43

CONCURRENT QUEUE

 Add to queue November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^44

CONCURRENT QUEUE - 2

 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

▪ 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

OBJECTIVES – 11/

 Consider a simple hash table

▪ Fixed (static) size

▪ Hash maps to a bucket

▪ Bucket is implemented using a concurrent linked list ▪ One lock per hash (bucket)

▪ Hash bucket is a linked lists

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^46

CONCURRENT HASH TABLE

 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

INSERT PERFORMANCE –

CONCURRENT HASH TABLE

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

CONCURRENT HASH TABLE

School of Engineering and Technology

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10. 94  Lock-free data structures in Java  Java.util.concurrent.atomic package  Classes: ▪ AtomicBoolean ▪ AtomicInteger ▪ AtomicIntegerArray ▪ AtomicIntegerFieldUpdater ▪ AtomicLong ▪ AtomicLongArray ▪ AtomicLongFieldUpdater ▪ AtomicReference  See: ht t ps://docs.oracle.com/en/java/javase/11/docs/api/ j ava.base /java/util/concurrent/atomic/package - summar y.html November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^50

LOCK-FREE DATA STRUCTURES

WE WILL RETURN AT 2:40PM November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10. 15  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

▪ 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.^52

OBJECTIVES – 11/

MIDTERM REVIEW November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10. 35  Thur sday November 4th  In Class in BHS 104 (2.0 hr s 1:30 – 3:30p)  Test designed to take less than 2 hour s  Two pages of notes, double - sided, any - size paper permitted  No book , other notes, cell phones, or internet  Basic calculators OK  Individual work  Coverage: all content up through Chapter 29, sloppy counter  P reparation:  Practice quiz: Quiz 2: CPU scheduling ( posted ) ▪ Auto grading w/ multiple attempts allowed as study aid  Practice– second hour of lecture ▪ Series of problems presented with some time to solve ▪ Will then work through solutions November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^54

MIDTERM

School of Engineering and Technology

 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

FIFO EXAMPLE

 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

Q1- SHORTEST JOB FIRST (SJF)

SCHEDULER

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

Q1 – SJF - 2

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

Q2 – SHORTEST TIME TO COMPLETION

FIRST (STCF) SCHEDULER

 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

Q2 – STCF - 2

  1. Provide a definition for what is a blocking API call
  2. Provide a definition for a non - blocking API call
  3. Provide an example of a blocking API call. Consider APIs used to manage processes and/or threads.
  4. Provide an example of a non - blocking API call. Consider APIs used to manage processes and/or threads. November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^60

Q3 - OPERATING SYSTEM APIs

School of Engineering and Technology

  1. When implementing memory synchronization for a multi-threaded program list one advantage of combining the use of a condition variable with a lock variable via the Linux C thread API calls: p t h r e a d _ m u t e x _ l o ck ( ) and p t h r e a d _ c o n d _ w a i t( )
  2. When implementing memory synchronization for a multi-threaded program using locks, list one disadvantage of using blocking thread API calls such as the Linux C thread API calls for: pthread_mutex_lock() and pthread_cond_wait()
  3. List (2) factor s that cause Linux blocking API calls to introduce overhead into programs: November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^61

Q4 – OPERATING SYSTEM APIs - II

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

Q5 – PERFECT MULTITASKING

OPERATING SYSTEM

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

Q6 – ROUND-ROBIN SCHEDULER

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

Q6 – RR SCHEDULER - 2

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:

  1. High number of Global Updates 2. High Per formance
  2. High Overhead 4. High Accuracy
  3. Low number of Global Updates 6. Low Per formance
  4. Low Overhead 8. Low Accuracy Low s loppy t hre shold ( S) H igh sloppy t hreshold ( S) | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^65

Q7 – SLOPPY COUNTER

 Review the bonus lecture for scheduling examples including several Multi-level-feedback-queue problems (MLFQ)

https://tinyurl.com/cxtau9zw

November 2, 2021 TCSS422: Operating Systems School of Engineering and Technology, University of Washington^ [Fall 2021] - Tacoma L10.^66

MULTI-LEVEL FEEDBACK QUEUE

School of Engineering and Technology

QUESTIONS