This document contains instructions and questions for several tutorials on the topic of operating systems. It provides guidance for students, such as maintaining a tutorial notebook and submitting assignments on time. It then lists 20 questions covering various operating system concepts like process scheduling algorithms, concurrency issues, and interprocess communication. Students are expected to answer the questions for the tutorials.
This document contains instructions and questions for several tutorials on the topic of operating systems. It provides guidance for students, such as maintaining a tutorial notebook and submitting assignments on time. It then lists 20 questions covering various operating system concepts like process scheduling algorithms, concurrency issues, and interprocess communication. Students are expected to answer the questions for the tutorials.
Jaypee Institute of Information Technology University, NOIDA
Odd Semester July 2014
Course Code: 10B11CI511 Course Name: Operating Systems Following instruction has to be followed in the tutorial class: 1. Maintain separate tutorial note book of atleast 200 pages. 2. All students are required to get their own scientific calculators. 3. Tutorials have to be submitted on the said days. 4. If tutorials are not submitted on the said days then tutorial marks will be made to Zero automatically. 5. Any absentees will also get zero for that tutorials.
Tutorial-1 (11-23 Aug) Introduction to OS
Q.1. Identify which of the following are examples of space multiplexing and which are time multiplexed sharing: (a) A door in a room. (b) A personal computer. (c) A telephone in home. (d) A printer on a timesharing system (e) News paper in a family (f) Bathroom in a family If you think that a particular case fit in both, explain.
Q.2. If we execute user programs in kernel mode what are the possible consequences? Which of the following instructions should be allowed only in kernel mode? (1) Disable all interrupts (2) Read the time of day clock (3) set the time of day clock (4) change the memory map
Q.3. Differentiate between batch processing, multiprogramming, multi tasking. Give two examples of each from your daily life.
Q.4. Define the essential properties of the following types of operating systems: a. Batch b. Interactive c. Time sharing d. Real time e. Distributed
Q 5. Given below a list of system service functions provided for the convenience of the programmer. Tell what each does. a) Program execution b) I/O Operations c) File system management. d) Communications e) Error detection
Q6. Identify several advantages and several disadvantages of open-source operating systems. Include the types of people who would find each aspect to be an advantage or a disadvantage.
Tutorial-2 (25 Aug-30 Aug)
Q1. Compare monolithic, layered, and micro kernel approach w.r.t (a) efficiency (b) Robustness (c) extensibility (d) security (e) ease of debugging (f) modularity Give proper justification.
Q2. What is spooling? Do you think that advanced personal computers will have spooling as a standard feature in the future?
Q3. On early computers, every byte of data read or written was directly handled by the CPU (i.e., there was no DMA).What implications does this organization have for multiprogramming
Q4. What is the key difference between a trap and an interrupt?
Q5. The client-server model is popular in distributed systems. Can it also be used in a single computer system?
Q6. What is the difference between a program and a process?
Q7. Writing an operating system that can operate without interference from malicious or undebugged user programs requires some hardware assistance. Name three hardware aids for writing an operating system, and describe how they could be used together to protect the operating system.
Q 8. How can the operating system detect an infinite loop in a program?
Q 9. In Fig.1, three process states are shown. In theory, with three states, there could be six transitions, two out of each state. However, only four transitions are shown. Are there any circumstances in which either or both of the missing transitions might occur?
Q 10. Put the following in the chronological order in the context of the birth of a process executes: Ready, suspended, execute, terminate, and create.
Tutorial-3 (1 Sept -13 Sept)
Q 1. Create an orphan process and Zombie process in UNIX operating system
Q 2. The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, .... Write a C program using the fork() system call that generates the Fibonacci sequence in the child process. The number of the sequence will be provided in the command line. For example, if 5 is provided, the first five numbers in the Fibonacci sequence will be output by the child
Q 3. Write a program in which Process A creates B and B creates C. The summation of two numbers (Two numbers should be passed as command line arguments) should be performed in C and the result returned to B as the exit status. B should double the summed value and returned the product to A as the exit status.
Q 4. Write a simple program print.c that takes two numbers as parameters, and repeats the first number the number of times given by the second number. Write a program call-print.c that uses execl() to call program print.c in two separate processes.
Q 5. What is the output of the following program? int main() { pid_t pid =fork(); if (pid ==0) { printf("I am the child\n"); exit(0); } wait(NULL); Ready Running Blocked 1 2 3 4 1. Scheduler picks another process. 2. Scheduler picks this process. 3. Input becomes available 4. Process blocks for input printf("I am the parent\n"); }
Q 6. What is the output of the above program if we remove the exit (0) statement?
Q 7. What is the output of the following program? int main() { int* var =(int *) malloc(sizeof(int)); *var =5;
pid_t pid =fork();
if (pid ==0) { (*var)++; printf("I am the child, var=%d\n", *var); exit(0); } wait(NULL); printf("I am the parent, var=%d\n", *var); }
Q8. Describe the differences among short-term, medium-term, and long term scheduling.
Q 9. Define following terms: a. Context switch b. Ready queue c. Swapping d. Degree of multiprogramming
Q 10. Which scheduling policy is most suitable for time-shared operating systems?
Q 11. Consider a set of n tasks with known runtimes r1, r2, rn to be run on a uniprocessor machine. Which processor scheduling algorithms will result in the maximum throughput?
Q 12. Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
Q 13. Assume that the following jobs are to be executed on a single processor system ----------------------- J ob-Id CPU-Burst Time ----------------------- p 4 q 1 r 8 s 1 t 2 ----------------------- The jobs are assumed to have arrived at time 0 and in the order p, q, r, s, t. Calculate the turnaround time for all jobs if scheduling is round robin with time slice 1.
Q 14. Four jobs to be executed on a single processor system arrive at time 0 in the order A, B, C, D. Their burst CPU time requirements are 4, 1, 8, 1 time units respectively. What is the average waiting time and average turnaround time for following scheduling algorithms? (a) round robin scheduling with time slice of one time unit (b) FCFS (c) SJ F
Q 15. Consider the following set of processes, with the arrival times and the CPU burst times given in milliseconds. ------------------------------------- Process Arrival-Time Burst-Time ------------------------------------- P1 0 5 P2 1 3 P3 2 3 P4 4 1 ------------------------------------- What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SROT) algorithm?
Q 16. Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. What will be the average turn around time?
Q 17. Write a program in C which uses a signal-handler function to count the number of times that the program receives SIGUSR1, one of the signals reserved for application use
Q 18. Consider following system Process Arrival time CPU burst time (ms) Priority A 0 22 1 B 0 12 2 C 0 23 2 D 0 11 3 E 0 21 2 F 0 15 3 G 30 22 3 Assume quantum =10 ms and 0 switching time, draw the Gantt chart and compute the average waiting time if the system is using multi-level queue scheduling(3 different queues Q1 with processes having priority 3, Q2 with processes having priority 2, Q3 with processes having priority 1) with no preemption . Each queue implements RR scheduling.
Q 19. Consider a multilevel feedback queue scheduling with three queues, numbered as Q1,Q2,Q3. The scheduler first executes processes in Q1, which is given a time quantum of 10 milli-seconds. If a process does not finish within this time, it is moved to the tail of the Q2.The scheduler executes processes in Q2 only when Q1 is empty. The process at the head of the Q2 is given a quantum of 16 milli-seconds.If it does not complete, it is preempted and is put into Q3. Processes in Q3 are run on an FCFS basis, only when Q1 and Q2 are empty. What is the average waiting time for following system?
Processes Arrival time Burst time P1 0 17 P2 12 25 P3 28 8 P4 36 32 P5 46 18
Q 20. Consider the following information and draw the timing (Gannt) chart for the processor and the I/O server using FCFS, SJ F and Round-robin scheduling algorithm(q=3) for processor scheduling and compute CPU utilization, average turnaround time and average waiting time.
Tutorial- 4 (15 Sept to 20 Sept) Q1. Define the meaning of a race condition? Use an execution sequence to illustrate your answer.
Q2. What is the critical section? A good solution to the critical section problem must satisfy three conditions, what are three conditions? Explain the meaning of each condition? Does starvation violate the progress condition?
Q3. Suppose N processes with IDs 0, 1, 2, , N - 1 need to share some critical region of code, which only one at a time is allowed to execute, and where they are required to repeatedly cycle through this section in the natural order (0, 1, 2, , N - 1). If turn is a shared integer variable initialized to zero, and current pid is the ID of the currently executing process, and each executes the following (pseudo) code, could a race condition occur? Why or why not? while( TRUE ) { while( turn !=current pid ) /* wait */ ; critical section( ); turn =(turn +1) % N; noncritical section ( ); }
Q4. Consider two processes Pi and Pj run concurrently. Also consider the following structures of each process. Is it meeting all the three conditions of critical section problem or not? Explain?
Q5. Change the structure of process Pi in the previous question to meet all conditions?
Q6. Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes: /* P1 */ while (true) { wants1 =true; while (wants2==true); /* Critical Section */ wants1=false; } /* Remainder section */
/* P2 */ while (true) { wants2 =true; while (wants1==true); /* Critical Section */ Wants2=false; } /* Remainder section */ Here, wants1 and wants2 are shared variables, which are initialized to false Determine whether this ensures mutual exclusion and bounded waiting?