Please work out the pre-lab problems before your next lab section. The GSI/IAs will go over all problems during the lab section.
Consider the following set of processes, with the length of the CPU-burst time given in milliseconds and with their priorities (larger priority numbers imply higher priority, and, in case of a tie, you can assume first-come-first- serve ordering). The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
Consider the following scheduling algorithms: First-Come-First-Served, Round-Robin (with quantum = 1), Shortest-Time-to-Completion-First, and a Non-preemptive priority. Assume context switching is free.
Consider typical considerations in designing CPU scheduling algorithms such as scheduling overhead, starvation/fairness, average response time, CPU utilization, and throughput. Discuss the advantages and disadvantages of the following scheduling algorithms: STCF, FCFS, round robin, non-preemptive priority, earliest-deadline first. Remember that the suitability of an algorithm often depends on the workload.
[pre-lab] A. Write a function job in C++ that is computationally expensive (e.g., sum the integers from 0 to 100000000). Measure the response time of job by calling gettimeofday at the beginning and end of the function. Compute the average response time of job by summing the response time of each execution of job, then dividing by the number of times job was called. job will be invoked by multiple threads, so make it thread safe (use C++ threading facilities).
[pre-lab] B. Write a program that calls job 32 times in a single thread. Measure the running time of the program, then print out the throughput of the program (number of jobs / running time of the program), and average response time for each job.
[in-lab] C. Speed up your program by using concurrency. Your program should still call job a total of 32 times, but it should do so in a configurable number of threads. Run the program with different numbers of threads (1, 2, 4, 8, 16, 32), and graph the average response time versus throughput as you vary the number of threads. What concurrency level produces the best (lowest) response time? What concurrency level produces the best (highest) throughput? What level of concurrency would you recommend running on this machine?