The following "parallel" code is given which contains two value entry commands (':') in variables. The two commands are

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

The following "parallel" code is given which contains two value entry commands (':') in variables. The two commands are

Post by answerhappygod »

The Following Parallel Code Is Given Which Contains Two Value Entry Commands In Variables The Two Commands Are 1
The Following Parallel Code Is Given Which Contains Two Value Entry Commands In Variables The Two Commands Are 1 (48.93 KiB) Viewed 28 times
The following "parallel" code is given which contains two value entry commands (':') in variables. The two commands are labeled E1 and E2, respectively. Assume that A and B are integer variables that initially have the values 8 and 3, respectively cobegin E1: A = A - : B; E2: B = B A; coend Give the final values that variables A and B can receive after the execution of the parallel code, taking into account all possible scenarios of execution (interleavings) of the commands in the following cases: a). In the case that each command is not executed individually-indivisibly but in two steps. More specifically: Command E1: A: = A - B is executed in two steps: • E1.1: T1: = A - B; /* the value of the difference A - B is initially calculated and entered in a register T1 * / • E1.2: A: = T1; /* then the value of register T1 is entered in variable A * / Command E2: B: = B-A is executed in two steps: • E2.1: T2: = B - A; /* the value of the difference B - A is initially calculated and entered in a T2 register */ • E2.2: B: = T2; /* then the value of register T2 is entered in variable B */ b). In case each command is not executed individually-indivisibly (but in two steps, as described above in sub- question [a]), and in addition for synchronization purposes a s1 semaphore (which is initially set to value 1) is used as follows: cobegin begin P(s1); E1: A A - B; V(s1); end begin P(s1); E2: BB- A; V(s1); end coend c). In the case where each command is not executed individually-indivisibly (but in two steps, as described above in sub-question [a]), and in addition two semaphores s1 and s2 are used for synchronization purposes (which are initialized to values 1 and 0, respectively) as following: cobegin begin P (s1); E1: A: = A - B; V (s2); end begin P (s2); E2: B: = B - A; V (s1); end coend
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply