CSE120  Problem set1 for Discussion Section - Oct 11th


From chapter 2 of text book
 

Problem 2:

A race condition is  asituation when two or more processes are about to perform some action. Depending on the exact timing, one or the other goes first. If one of the processes goes first, everything is fine; but if the other goes first, a fatal error occurs.

Problem 3:

With busy waiting, a process keeps testing for some condition. It consumes cpu cycles in a tight loop. with blocking, a process gives up the cpu and is awakened later when the condition it is waiting for has become true. A blocked process does not use the cpu.

Problem 8:

To do a semaphore operation, the os first disables interrupts.
 
Then it reads the value of the semaphore. For a DOWN operation, if the semaphore is 0, the calling process is put in the list of blocked processes associated with the semaphore.
 
For an UP operation, it checks to see if there are processes blocked on that semaphore and if so, one of them is made ready (runnable); if none is blocked the semaphore is incremented.

The os now enables the interrupts.