Question

Question1: Consider the following two threads of a process, to be run concurrently in a shared memory (all variables are shared between the two threads): Thread A Thread B for (i 0; i<5 i++) for (j 0; j<5 j++) x x 1 x x 2 Assume the following: 1. a single-core system 2. load and store are atomic (i.e. they start and finish without interruption) 3. x is initialized to 0 before either thread starts, and 4. x must be loaded into a register before being incremented (and stored back to memory afterwards). The following questions consider the final value of x after both threads have completed. 1a. [5 pts]: State the upper and lower bounds of value of x when both threads have completed. Explain your answer.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thread A, for each execution it is making X value increment by 1, it is executing 5 times so it increments x value X+5.

Thread B, for each execution it increments x value as X+2, it is executing 5 times so it increments x value as X+10.

(り A co)2 e t baed on e hseod /e. ti) in.人tarte bacle the Value inele aftes Comple iorn

If there is a possibility of interrupt between these 3 operations thn consider the below scenarios for max and min value of X.

este ert ri ecui tonMax vale

Add a comment
Know the answer?
Add Answer to:
Consider the following two threads of a process, to be run concurrently in a shared memory...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Do the following project: Following is the file to be programmed in Linux kernel. Run this...

    Do the following project: Following is the file to be programmed in Linux kernel. Run this program. Include the screenshot of the results. Multi threaded Sorting Application Write a multithreaded sorting program that works as follows: A list of integers is divided into two smaller lists of equal size. Two separate threads (which we will term sorting threads) sort each sub list using a sorting algorithm of your choice. The two sub lists are then merged by a third thread—a...

  • Given the following information, Construct the PDM network and use the information given in the following...

    Given the following information, Construct the PDM network and use the information given in the following table, calculate ES, EF, LS, LF and the critical activities. Project Data: 1-U and R can be performed concurrently and both begin on the start of the project. 2-Activity X is independent of both activities Q and K 3-E must start before work on activity K can begin. 4-Neither activity F nor activity G can start before activity R start. However, activities F and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT