Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Three cooperating processes: P1, P2, and P3 execute concurrently. Each process computes its functions independently and repeatedly within its own infinite loop see below.

1. Three cooperating processes: P1, P2, and P3 execute concurrently. Each process computes its functions independently and repeatedly within its own infinite loop see below. However, between each iteration of its loop, P1, P2, and P3 synchronize according to the diagram below: A process cannot cross the line to execute its next function until its peer is prepared to also cross the line. For instance, P1, P2, and P3 cannot cross the red line until all 3 processes complete execution of f1(), f2(), and f3(). Similarly, P2 and P3 cannot cross the blue line until they both complete execution of g2() and g3(); however, P1 may proceed to execute h1() as soon as it completes its execution of g1(). Construct a well-written pseudo code to solve the above problem 1, using only semaphores. Explain the usage of each semaphore in your pseudo code. Student may assume that each process and shared resources have been properly instantiated.

image text in transcribed

2. Consider the execution of 7 processes that behave as follows: Proc A is tasked with printing letter A, ProcB outputs letter B, ProcC outputs letter C, and ProcD prints letter D indefinitely. Each process outputs its letter repeatedly when it gets its tokens to execute. One of ProcA, ProcB, ProcC & ProcD process gets its token to execute after this process has secured a token from either Proc0 or Proc1, and another token from process Proc* (described below). Moreover, each process ProcA, ProcB, ProcC & ProcD needs to secure its token from either Proc0 or Proc1 before it requests its token from Proc*. Lastly, for each iteration each process ProcA, ProcB, ProcC & ProcD gets a random integer to decide whether to request a token from Proc0 or Proc1. For instance, ProcA gets a random even integer, and gets its token from Proc0, then gets its token from Proc* before it can prints its letter A. Proc0 independently assigns a token to one of ProcA, ProcB, ProcC & ProcD in first-comefirst-serve fashion (i.e., each process gets its turn according to the order that the process asks Proc0 for a token) and each token is mutually exclusive (i.e., one process finishes its token before the next gets its token). For example, if ProcD requests Proc0 for a token before ProcA makes a request, then Proc0 assigns a token to ProcD, provided that no other process is currently using its token. Exactly like Proc0, Proc1 independently assigns a token to one of ProcA, ProcB, ProcC & ProcD with first-come-first-serve discipline and mutual exclusion. Lastly, Proc* independently assigns a token to one of ProcA, ProcB, ProcC & ProcD mutual exclusively too; in other words, Proc* allows at most one process to get a token. Proc* determines which process gets a token based on the alphabetical order of the names of the processes requesting the token. That is, ProcA always gets its token before all other processes, if it had asked for a token before Proc* passes out its next token. It also follows that ProcD only gets a token when no other process is asking Proc* for a token. Assume that each process ProcA, ProcB, ProcC & ProcD execute with arbitrary and unpredictable delays. Also, assume that the semaphore V operation is implemented such that a process is resumed in the order that it is blocked by the P operation. Therefore, if ProcC executes P(SAMPLE) and blocks before ProcA executes P(SAMPLE) and blocks, ProcC is certain to be resumed before ProcA when V(SAMPLE) operation executes. Construct a well-written pseudo code to solve the above problem 1, using shared memory and semaphores. Explain the usage of each semaphore in your pseudo code. Student may assume that each process and shared resources have been properly instantiated.

3. A work area is divided into 4 regions: A0, A1, B0, B1. The work area can be occupied some robots. Each of the robots is managed by a separate process. Assume that any robot can remain in its resting position outside the work area (when it's not using a work area) and that a robot can more freely in and out of the work area without interfering with other robots. The following rules of work space must be observed: When one robot occupies square A0, the other robot must not occupy squares A0 and A1; and when one robot occupies square B0, the other robot must not occupy squares B0 and A0. Moreover, no robot can occupy the same square. As shown in the illustration, while one robot occupies square A0, one other robot can occupy square B1. But, while one robot occupies square B0, the others can occupy either squares A1 and/or B1. The pseudo code defines the operations of each robot.

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago