Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

question b st 02.pdf x lesson 12- i-o syste.. +) 100% ECE4 CI450/IMSE 450 Operat

ID: 3919714 • Letter: Q

Question

   question b

st 02.pdf x lesson 12- i-o syste.. +) 100% ECE4 CI450/IMSE 450 Operating System term test 2, July 2015 You have 1 hour and 45 min o complete this test. State your answers cleary 1. (20 points) a) Two concurrently running processes: PI with a statement S1 and P2 with a statement S2. Use the semaphore to synchronize both processes that make SI executed only after S2 has completed. State the initial value of the semaphore. sghal (s1) b) What will happen when a process implements semaphore as signal.. wait instead of So SI wait signal? The Semaphenitih 2ero be sc c) What will happen when a process implements semaphore as waits)... wait(s) instead of wait(s) , , , signal (s)? 2. 130 points DOLL

Explanation / Answer

If the process is implemented as

P() {
signal(p)
wait(p)
}

Then during the signal, there is no blocking but when it executes wait there may be
blocking. As soon as the signal instruction gets executed, some other process
which is waiting on semaphore p will be woken up and in that case the other process
will run and this process will wait till the other process finishes and execute the
signal call. Semaphore initialized state (whether 0 or 1) will not have much impact on
the exexution of this process.


If the process is implemented as

P() {
wait(p)
signal(p)
}

In this case the process blocks if the semaphore is not available, but if emaphore
is available it will not block and then when it executes signal instruction , then as stated in the above part some other process may or may not start.If some other process starts up then in the next execution of wait it will block till the other process executes signal.

The behaviour will be different based on semaphore initialization.If it is initialized to
0, and nobody has done signal on it then wait will block in the first occurence itself, the process will wait till some other process executes signal on that semaphore.