Hm Os4

Submitted by: Submitted by

Views: 155

Words: 1412

Pages: 6

Category: Other Topics

Date Submitted: 11/10/2012 04:32 AM

Report This Essay

Homework4

Process Synchronization

1. What is a Race condition? Describe the steps involved that might result in a Race condition for two threads accessing the same shared global variable b.

We allowed both processes to manipulate the variable counter concurrently. A situation like this, where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is call a race condition. To guard against the race condition above, we need to ensure that only one process at time can be manipulating the variable counter. To make such a guarantee, we require that the processes be synchronized in some way.

Situations such as the one just described occur frequently in operating systems as different parts of the system manipulate resources. Furthermore, with the growth of multi core system, there is an increased emphasis on developing multithreaded applications wherein several threads – which are quite possibly sharing data – are running in parallel on different processing cores. Cleary, we want any change that result from such activities not to interfere with one another. Because of the importance of this issue, a major portion of this chapter is concerned with process synchronization and coordination amongst cooperating processes.

2. What is a critical section? Name and explain the 3 requirements for a solution to the critical selection problem.

Consider a system consisting of n processes {P0, P1, …., Pn-1}. Each process has a segment of code, called a critical section, in which the process may be changing common variable, updating a table, writing a file, and so on. The important feature of the system is that, when one process is executing in its critical section, no other process is to be allowed to execute in its critical section. That I, no two processes are executing in their critical sections at the same time.

A solution to the critical-section problem...