Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Consider the following portions of two different programs running at the same time on four processors in a symmetric multi-core processor (SMP). Assume that before this code is run, both x and y are 0.

Core 1: x = 2;

Core 2: y = 2;

Core 3: w = x + y + 1;

Core 4: z = x + y;

6.7.1 [10] What are all the possible resulting values of w, x, y, and z? For each possible outcome, explain how we might arrive at those values. You will need to examine all possible interleaving’s of instructions

6.7.2 [5] How could you make the execution more deterministic so that only one set of values is possible?

Short Answer

Expert verified

a) The possible resulting values of the x, y, w and z are as below

x,y,w,z=2,2,1,0,2,2,3,0,2,2,5,0,2,2,1,2,2,2,3,2,2,2,5,2,2,2,1,4,2,2,3,4,3,2,5,4

b) Synchronizations are very helpful to get only one set of values.

Step by step solution

01

Symmetric Multicore Processor

If a processor has all similar cores in it, then it is called a Symmetric multicore processor. Intel core 2 Is the best example of a symmetric multi-core processor. The multi-cores are extremely useful, the program can be ruined by the multiple threads and ultimately helps the process to complete faster. In most cases, a single thread divides into multiple threads and even the communication between threads becomes more complicated and costly. The multi-processor is extremely helpful in those cases. Symmetric multicore processors are easy to design because after designing a single processor, we can simply replicate the other processors. All the processors in symmetric multicore processors share the same memory and I/o devices and the same function can be performed by all of them.

02

(6.7.1)Step 2: Resulting values of w, x, y and z

From the above question, we can see that we are using the symmetric multi-core processor for the operations. Cores 1 and 2 are used to assign the values for x and y variables. The core 3 is used for the sum of x, y, and 1. The core 4 is used as the sum of the x and y.

The possible resulting values of the x,y,w and z are as below

x,y,w,z=2,2,1,0,2,2,3,0,2,2,5,0,2,2,1,2,2,2,3,2,2,2,5,2,2,2,1,4,2,2,3,4,3,2,5,4

The value of y is going to same in all the possible values because no core is trying to change the value of y. the value of w changes from 1 to 5 and the maximum value is 5. Because w is assigned with the sum of x, y, and 1. The values of z are varied from 0 to 4 because z is assigned with the sum of x and y.

03

(6.7.2)Step 3: Deterministic execution

As different processors are working on the different data variables or nodes. This may lead to a deadlock situation. It's always better to avoid a deadlock situation when different processes are handled by different processors. To solve the problem we can implement synchronization methods. As a result, only one processor can access the data or do one process. The process may be any operation like reading data, writing data, and doing any arithmetic calculation. Synchronizations are the mechanism built on the subroutines that rely on hardware-supplied synchronization. Synchronization is the process of setting up coordination between processes when they are being held or used by more than two processors. So, the simple solution for the above problems is to use synchronization.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free