A. Fill in the blanks of the following sentences: a) Operating System controls and coordinates use of hardware among various applications and users. b) In simple batch systems, Spooling which refers to transferring input onto a temporary working area to be later accessed by another program is used to improve performance. c) In Symetric Multiprocessing each processor runs and identical copy of the operating system which communicates with each other as needed. d) In computer systems generally we have two communication models. With these models communication may take place using either shared memory or message passing . e) A process is a program in execution. B. Specify whether the following statements are true or false. a) The main advantage of distributed systems is that they allow shared memory model type communication between processes. …F. b) The next process to get CPU is selected using synchronization algorithm. ……F…. c) Two processes can not be in their running states at a given time. ……T.. d) Device controller informs CPU that it has finished its operation by causing an interrupt. ……T…. e) Hard disks and CD-ROMs are volatile storage mediums. …F……. Q.2. [15 pts] Consider the following program: Shared data bool lock[2] = { false, false }; // In shared memory int turn = 0; // In shared memory Process Pi // i can be 0 or 1; process id int other; do{ other = 1 - i; lock[i] = true; while ( turn != i ) { while ( lock[other] ); turn = i; } critical_section(); lock[i] = false; remainder_section(); }while(true); This is proposed as a software solution for synchronization of two concurrent processes. Explain whether it satisfies all three requirements or not? Solution: 1. Mutual exclusion is satisfied. While one process running in its CS other process should wait in while (lock[other] ); loop. 2. Progress is satisfied. While one process running in its remainder section other process can continue and go in its CS because of the lines: while ( turn != i ) { while ( lock[other] ); turn = i; } 3. Bounded waiting is not satisfied because while one process waiting in while (lock[other] ); loop other process can go into its CS more than once Q.3. [25 pts] Given the following table, how will these processes be scheduled using FCFS, SJF and SRTF algorithms? Create a Gantt chart showing when each process will be scheduled, and calculate the waiting times and turnaround times for the processes for each scheduling algorithm. Process P0 P1 P2 P3 P4 CPU-Burst time 6 2 7 1 3 Arrival time 0 3 4 7 8 (FCFC) CPU Gantt Chart: P0 P1 0 6 P2 8 P3 15 P4 16 19 (SJF) CPU Gantt Chart: P1 P0 0 6 P3 8 P4 9 P2 12 19 (SRTF) CPU Gantt Chart: P1 P0 0 3 P0 5 FCFS SJF SRTF FCFS SJF SRTF P3 8 P4 9 P2 12 W(P0) 0 0 2 W(P1) 3 3 0 W(P2) 4 8 8 W(P3) 8 1 1 tat(P0) 6 6 8 tat(P1) 5 5 2 tat(P2) 11 15 15 tat(P3) 9 2 2 W(P4) 8 1 1 tat(P4) 11 4 4 19 Q.4. [30 pts] Consider the following process arrival, CPU and I/O burst times. Assume that only one I/O device is available and it operates using FCFS algorithm. Assume that there is only one CPU and it uses SRTF algorithm. Process A B C Arrival time 0 3 5 CPU 7 5 1 I/O 6 2 10 CPU 2 1 6 Draw the Gantt charts for the CPU and I/O device to compute the waiting time and turnaround time (tat) of all processes and CPU utilization. Put your answers into the table given below. CPU Gantt Chart A 0 C 5 A 6 C B 8 13 16 A 22 B 24 25 I/O Gantt Chart C 0 A 6 16 B 22 Wait(A) Wait(B) Wait(C) Tat(A) Tat(B) Tat(C) 1 5 0 24 22 17 24 CPU utilization (22/25)x100% Q.5. [20 pts]The processes A, B and C are synchronized as given below. Answer the following questions by analyzing the given code. Assume that shared data may be used in produceA, produceB and produceC parts of the programs. Shared data: Semaphore s1=0, s2=0; Processs A: { } Process B: { Process C: { wait(s1); wait(s2); //produceA; //produceB; //produceC; signal(s1); signal(s2); } } a) The execution can be in the order: first produceA, then produceB, then produceC. ……T…. (T/F) b) A race condition may occur between process A and process C. ……F…. (T/F) c) If the semaphore variables are initialized as s1=0 and s2=1, produceC, then produceB, then produceA will be a possible sequence. ……F…. (T/F) d) If the semaphore variables are initialized as s1=0 and s2=1, produceC, then produceA, then produceB will be a possible sequence. ……T…. (T/F) e) If the semaphore variables are initialized as s1=0 and s2=1, a race condition may occur between process A and process C. ……T…. (T/F) REMARK FOR Q.5.: ANSWER THE PARTS THAT YOU ARE SURE. YOU WILL GET NEGATIVE GRADES FROM WRONG PARTS