You are on page 1of 7
PM Vern 2931S - 291 WENe_ wa -02, BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI— K. K. BIRLA GOA CAMPUS First Semester 2013-2014 Course Title |: OPERATING SYSTEMS ‘Course No CS C372 , IS C362, CS F 372 and IS F 372 Component: Test I (Regular) Closed Book Component Weightage : 20% Max Marks: 40 Date: 17-09-2013 Question No. 1 109 Marks] Draw the process tree for the given program and find the final value of variable x for each process. int main) { int x=30; ifffork()){ x—-=20; if!forkO){ iftfork(){ xX--3 } x +40; } else x += 50; } while(wait(NULL)!=-1); return 0; } Question No. 2 [09 Marks] Consider 4 processes A, B, C and D in a Uniprocessor system. xPy represents process P goes for x units of VO operation after every y units of execution. Following table shows arrival time, execution time and xPy for all the processes. Scheduling policy is as follows: Assume there are only 3 queues Qo , Q: and Q with priorities 0, 1 and 2 respectively. Queues Qo and Q, follows Round Robin with time quantum 1 and 2 respectively. Queue Q2 follows FCES. Process enters in initially and after completing /O operation. If a process is preempted by a process in higher priority queue, preempted process remains in the same queue at same position (j.e at head of the queue) with remaining time quantum. If time quantum of a process expires, process is moved to the next lower priority queue. Process | Arrival | Execution xPy Time | Time A lo 7 ae B 2 > 2Bs re IEG [CPU bound D 8 8 ea Draw the schedule according to Multilevel Feedback Scheduling algorithm. Question No. 3 [06 Marks} Consider 4 processes scheduled according to shortest remaining time first algorithm whose Gnatt chart is as shown below. Calculate turnaround time of each process and average waiting period by filling the following table. i P| BTR BTR Ic ©7346 8 Io li 18 te tz a0 2 30 =e Process | Arrival time Turn-around time | Execution Period | Waiting period A 0 7 B 2 9 c 4 6 D 6 8 Average Waiting Period Question No. 4 [07 Marks} Consider a Linux OS supporting O(1) scheduler. a) Give equation to calculate Static Priority, Time Quantum and Dynamic Priority. b) Fill the following table and find quantum time allotted to each process and Dynamic priority of all conventional processes Process | Nice [ Avg sleep | Bonus | Quantum | Dynamic | Scheduling policy time(ms) Time(ms) | Priority A -10 [220ms | SCHED_OTHER B 13 | 160ms SCHED_OTHER G “5 | 280ms [ SCHED_RR D 0 | 650ms [ SCHED_FCFS Question No.5 [09 Marks} Consider a process transition model with seven states and complete the following table to explain state transitions under the given condition. VO | Memory | State Ready | Ready- Blocked | Blocked- Suspend Suspend f Ready-Suspend Blocked Blocked-Suspend BM Dewm TVS TAK Tia wo-02, ec BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI-K. K. BIRLA GOA CAMPUS First Semester 2013-2014 Course Title: OPERATING SYSTEMS Course No CS C372, IS C362, CS F 372 and IS F 372 ID No Nam Question 5: Complete the following ¢ code. Assume all required header files are included (12) Following program is to search an element from the array of integers using multithreaded programming concept. The program reads the number of threads to be created as command line argument from the user and logically divides the array into sub arrays such that each sub array is searched by a single thread to find the key element. The key is searched in all sub arrays simultaneously. The thread which finds the key returns the index of key to the main thread else returns -1. All the threads stop searching once the key is found. The main thread displays whether the key element is found or not found. If the key is found index position and the thread no (not thread id) of the thread that has found the key is displayed. Note: The program should work for any array size, key is the value to be searched, a is an array of integers, variable found is to test whether key is found or not found, variable begin is to start execution of thread only after creation of all and m is the number of threads. r is array of value returned by thread #define MAXSIZE 50 int n, key, begin=found=0; startindex= B int a[MAXSIZE]; void* search(void *index) eoeenesia { ; int i,j; j=(int) (intptr_t) index; while (begin=-0); } for (i=0; pit+) begin=1; ; for (i=0;i- “Assume that all the processes are ready at time 0. Total CPU execution time for the units /O after 40 units of CPU processes is 10, 30, 40, 30 and 60 respectively. P2 goes for 20 ‘execution. P4 goes for 70 units 1/0 after 30 units of CPU cxecution, PO, Pl and P3 are completely CPU pound processes. CPU is fairly shared amongst the two groups with 25% to Group | 116, 118, 119 and 117 respective point, calculate the priorities of rind 75% to Group 2. The base priority of the procesSt is 120, fly. Consider time quantum of 30 units. At each scheduling the processes and schedule the process with highest priority {Gmallest integer). Whenever a process retums from VO, its CPU count is set to 0, group count is orto the group count of other processes in the same ETOUR ‘and the PRIORITY is calculated with base priority, CPU count and group count values. Draw the table which shows the PRIORITY, CPU count and Group count at each decision point. Draw Gantt chart for the schedule. Question#9 [8 Marks] Catsider the following snapshot at time t in a Uniprocesso™ system. Process P goes for x units of VO operation after every y units © ff execution is represented as_xPY. Process | Arrival time | Total Execution time | xPy A 0 8 2A3 B 2 5 5B2 c 3 7 ‘CPU bound D 5 8 3D4 ‘ind the resultant schedule and epresent it as Gantt chart with Virtual Round Robin epaduling algorithm. Consider the time quantum of 4 units. Find average waiting period. 4/4 =

You might also like