CS439: Principles of Computer Systems
Discussion Section 3 Problem Set
Due in Section on Friday, February 6, 2026
The problem set must be completed before section and brought to section. To
ensure that your problem set is turned in correctly and that you receive credit
for discussion section, you must follow these guidelines exactly.
-
How can fairness and throughput be competing goals for a scheduler?
Give an example where a fair scheduler makes bad use of the CPU and an
example where a high-throughput scheduler is unfair.
-
Most round-robin schedulers use a fixed size quantum. Give an
argument in favor of and against a small quantum.
-
Consider a system using a multilevel feedback queue scheduler. Its scheduler is
configured to have four queues, which are, in order of highest priority to
lowest priority: Q1, Q2, Q3, and Q4. The queues have quantums sized 5s, 10s,
20s, and 40s, respectively.
For each of the following three processes, determine which queue it is in when
it begins its final quantum.
- Process A, runtime 40s, blocks every 2s.
- Process B, runtime 42s, never blocks.
- Process C, runtime 70s, blocks at 7s, 11s, 25s, 42s, 48s, where those times
are points in its execution.
-
In the code below, indicate where each variable is stored (e.g.,
stack, heap, static data segment), and whether that variable would be
shared by the threads in a multi-threaded program. If applicable,
indicate where the space that variable points to is allocated.
int i; //static data segment, shared
char * j; //static data segment, shared, no memory yet!
void foo(int a){
int b; //stack, not shared
static float c; //static data segment, shared
/*do stuff*/
}
int main(int argc, char**argv){
int * m; //stack, not shared, no memory yet!
int g; //stack, not shared
double z; //stack, not shared
j = malloc(MAXBUF*sizeof(char)); //heap, pointer shared, memory shared
createThread(0, foo(), 2);
createThread(1, foo(), 4);
/*do stuff*/
}
-
Compare and contrast monitors and semaphores. What is an appropriate
use of each?
-
You need two Hydrogen atoms and one Oxygen atom to make water.
Using semaphores, write a pseudocode solution that generates water whenever the
right resources are available. You must have three functions: one to
generate Oxygen, one to generate Hydrogen, and one to generate water.
Assume the three methods may be executed by any number of threads
concurrently.
-
Solve the water problem using monitors (pseudocode).
|