A. Spin Lock: a Semaphore Which Adopts Busy Waiting While a Process Is Waiting for the Lock
Total Page:16
File Type:pdf, Size:1020Kb
1. Terminologies a. Spin Lock: A semaphore which adopts busy waiting while a process is waiting for the lock. b. Checkpoint: Output all logs onto stable storage. Output DB, and write
2. Please compare user-level and kernel-level threads. Sol: User-level threads are implemented by a thread library at the user level. Advantages: Context switching by a thread library at the user level. Disadvantages: Blocking of a thread in executing a system call can block the entire process. Kernel-level threads are provided a set of system calls similar to those of processes. Advantages: Blocking of a thread will not block its entire task. Disadvantages: Context switching cost is a little bit higher because the kernel must do the switching
3. Please answer the following questions on process schedule. a. Please define nonpreemptive and preemptive scheduling b. In Solaris 2, process priorities are classified in to 4 classes: Real time, System, Time-Sharing, Interactive. Please pick up any class that adopts multilevel feedback queue scheduling. c. Please briefly describe the Linux time-sharing scheduling algorithm based on credits. Sol: a. Nonpreemptive Scheduling: A running process keeps CPU until it volunteers to release CPU, e.g., I/O or termination. Preemptive Scheduling: Beside the instances for nonpreemptive scheduling. CPU scheduling occurs whenever some process becomes ready or the running process leaves the running state. b. Time-Sharing, Interactive. c. A Time-Sharing Algorithm for Fairness. The process with the most credit is scheduled Recrediting when no runnable process has any credits: Credits = (credits/2)+priority. Mixture of a history and its priority.
4. Given the following process set, please draw the Gantt Chart of the process executions under the selected scheduling algorithm. All processes are ready at time 0. Please also compute the average waiting time for each selected scheduling algorithm.
Process CPU Burst Time P1 10 P2 8 P3 6 P4 4 a. Shortest Job First Scheduling (0+4+10+18)/4=8 b. Round Robin Scheduling with Time Slice = 4. (18+16+20+12)/4 = 16.5
5. What are the other two requirements beside “bounded waiting” for a solution to the critical section problem. Please decide whether the following implementation satisfies the “bounded waiting” requirement. You must give me your proof. Do{ while(TestAndSet(lock)); critical section lock = false; remainder section }while (1);
Sol: (1) Mutual exclusion, progress, and bounded waiting (2) No