3
Subject: Operating Systems Q.1 Consider that a multiprogrammed system has a load of N processes with individual total execution times of t 1 , t 2, t 3, …….., t N , How would it be possible that T > (t 1 + t 2 + t 3, …….. + t N ) ? where T is total execution time. That is, what could (two) causes the total execution time to exceed the sum of the individual process execution times? Ans. The execution time could exceed the sum of the individual execution times if the system was unable to overlap I/O with processing, even across processes and switching time among processes. That is, there will be times when the CPU is idle, yet the system is performing I/O for some of the processes. Q.2 Classify the following applications as batch-oriented or interactive. Justify your answer. (Attempt any five) a. Word processing: Interactive b. Generating monthly bank statements: Batch c. Computing pi to a million decimal places: Batch This job is 100% CPU-bound. A batch system without multiprogramming would attain nearly 100% CPU utilization running this program. d. Generating personal 1040 tax returns: Interactive e. Generating employee W-2 tax forms: Batch f. A flight Simulator: Interactive Q. 3 Indicate how mutual exclusion could be implemented using mailboxes with non-blocking send_mailbox and blocking receive_mailbox primitives. Assume the primitives are executed as indivisible atomic operations. Ans. After creating and initializing a mailbox mutex to have a single message, any process wishing to enter its critical section must attempt to receive a message. Only when a process actually receives a message can it enter its critical section. When it leaves its critical section, it returns the message it received back to the mailbox. Since there is only one message, only one process message, only one process can be in its critical section at a time. //critical section receive_mailbox (mutex, message); send_mailbox (mutex, message);

Sessional 1 Ans - Copy

Embed Size (px)

Citation preview

Subject: Operating Systems

Q.1 Consider that a multiprogrammed system has a load of N processes with individual total execution times of t1, t2, t3, …….., tN , How would it be possible that T > (t1 + t2 + t3, ……..+ tN ) ? where T is total execution time.That is, what could (two) causes the total execution time to exceed the sum of the individual process execution times?Ans. The execution time could exceed the sum of the individual execution times if the system was unable to overlap I/O with processing, even across processes and switching time among processes. That is, there will be times when the CPU is idle, yet the system is performing I/O for some of the processes.

Q.2 Classify the following applications as batch-oriented or interactive. Justify your answer. (Attempt any five)

a. Word processing: Interactiveb. Generating monthly bank statements: Batchc. Computing pi to a million decimal places: Batch This job is 100% CPU-bound.

A batch system without multiprogramming would attain nearly 100% CPU utilization running this program.

d. Generating personal 1040 tax returns: Interactivee. Generating employee W-2 tax forms: Batchf. A flight Simulator: Interactive

Q. 3 Indicate how mutual exclusion could be implemented using mailboxes with non-blocking send_mailbox and blocking receive_mailbox primitives. Assume the primitives are executed as indivisible atomic operations.

Ans. After creating and initializing a mailbox mutex to have a single message, any process wishing to enter its critical section must attempt to receive a message. Only when a process actually receives a message can it enter its critical section. When it leaves its critical section, it returns the message it received back to the mailbox. Since there is only one message, only one process message, only one process can be in its critical section at a time.

//critical section

Q. 4 Complete the following scenario, it is related to Interprocess Communication Patterns (Write your answer in very short to the point (as possible)) Process competition for resources

Context: the use of shared resources physical and logical resources serially reusable resources

Problem: race conditions Where the problem occurs: critical sections Abstract solution: atomic actions Concrete solution: mutual exclusion (of critical sections)

Q: 5 Answer:If a processor occurs more than once in the round-robin list, then it will get two turns for

receive_mailbox (mutex, message);

send_mailbox (mutex, message);

each pass through the list. One reason for allowing this would be to implement aprimitive priority system since the more times it occurs on the list, the higher thepercentage of time the CPU will spend on that process.

Q: 6Answer:There is a possibility of starvation here. Suppose process j is in critical section andprocess i is busy waiting at the inner while loop. Now when process j exits the criticalsection it sets turn = i, but it immediately tried to access the critical section and so setsinside[j] = true. Right before process j executes “while (inside[i])”, scheduler schedulesprocess i. Now process i exits from the inner while loop as turn = = i now, but it findsinside[j] to be true so continue the outer while loop. Then after it executes“inside[i]=false”, the scheduler schedules process j and it finds the condition at outerwhile loop to be false and enters the critical section. As a result, process i busy waits atouter while loop. These steps can repeat arbitrary number of times and that starvesprocess i and it may never enter the critical section. In the original algorithm, there is anextra checking “if (turn==j)” which ensures that this starvation never happens.