![]() Now, it decrements the value of x by 2.This can be achieved if processes execute in the following manner. ![]() The impact of processes W and X gets lost on the value of x.Only the impact of the processes Y and Z remains on the value of x.To obtain the minimum value of x, the processes must execute in such a way that. In problem-03, what is the minimum possible value of x after all processes complete execution? This is the maximum possible value of x that can be achieved after executing all the 4 processes.Now, execution of process X is completed.It writes the value x = 2 in the memory.Now, execution of process W is completed.It executes the signal(S) operation and the value of S increments by 1.It writes the value x = 1 in the memory.Now, it increments the value of x by 1.Before preemption it had already read the value x = 0.It resumes its execution from where it left.Now, execution of process Z is completed.It writes the value x = -4 in the memory.Now, execution of process Y is completed.It writes the value x = -2 in the memory.It executes the wait(S) operation and the value of S decrements by 1.Here, the lost update problem has been exploited.Later, execute process X which again increments the value of x.The updates from the processes Y and Z gets lost.This is because before preemption it had read the value x = 0.Now, when process W gets scheduled again, it starts with value x = 0 and increments this value.After executing them, reschedule process W.Now, schedule process Y and process Z to execute one by one.First of all, make the process W read the value of x = 0.The impact of processes Y and Z gets lost on the value of x.Only the impact of the processes W and X remains on the value of x.To obtain the maximum value of x, the processes must execute in such a way that. Processes Y and Z decrements the value of x.Processes W and X increments the value of x.Now, We have been asked the maximum possible value of x after all the processes complete execution. Initially, counting semaphore S is initialized with value 2. The given question may be pictorially represented as. What is the maximum possible value of x after all processes complete execution? signal) on the semaphore S after storing x to memory. wait) on a counting semaphore S and invokes the V operation (i.e. Each process before reading x invokes the P operation (i.e. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each of the processes W and X reads x from memory, increments by one, stores it to memory and then terminates. V operation also called as signal operation increments the value of semaphore variable by 1.Ī shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows.P operation also called as wait operation decrements the value of semaphore variable by 1.Then, 20 P operations and 15 V operations are performed on S. A counting semaphore S is initialized to 7.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |