Computers and Technology

The goal of this assignment is to write a multithreaded program that explores synchronization challenge. For this part, assume that, we have a shared variable NextID. This is initialized to 1 at the beginning.
Now create 5 threads in your program and assign ID 1, 2, 3, 4, 5 to them respectively. You can pass the ID as a parameter when you create the threads.
Each of the threads will try to access the variable "NextID".
Whenever a thread acquires the variable, it checks whether the NextId is equal to its own Id or not.
If it is not equal, it will output "Not My Turn!", then print its threadId, and then release the variable.
If it is equal, the thread will print ""My turn!", then print its threadId, increase the NextId by 1, and then release the variable. However, after increasing NextID by 1, the thread will check if the value is 6 or not. If it is 6, it will reset it to 1 before releasing the variable.
The program should execute until each thread prints "Mu Turn!" 20 times. Once a thread prints for 20 times, it terminates.
Count the number of times each thread prints "Not my Turn!" and include that in the report.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, loveworld3798
When working with a team you should always do the following, except? question 3 options: be dependable and trustworthy be sensitive to others feelings do your fair share critique members of the group
Answers: 2
image
Computers and Technology, 22.06.2019 14:10, normarismendoza
Dean wants a quick way to look up staff members by their staff id. in cell q3, nest the existing vlookup function in an iferror function. if the vlookup function returns an error result, the text “invalid staff id” should be displayed by the formula. (hint: you can test that this formula is working by changing the value in cell q2 to 0, but remember to set the value of cell q2 back to 1036 when the testing is complete.)
Answers: 3
image
Computers and Technology, 22.06.2019 19:20, sindy35111
Terri needs to insert a cover page into her document. where should she go to access the commands to do so? o insert tab, objects group o insert tab, illustrations group o insert tab, pages group o insert tab, media group submit
Answers: 1
image
Computers and Technology, 22.06.2019 22:40, ihatemylife0
Least square fit to polynomial write a function leastsquarefit3pol that solves a linear system of equations to find a least squares fit of a third order polynomial to an experimental data set given as two row arrays. the function leastsquarefit3pol must explicitly solve a set of linear equations and cannot use polyfit. there should be no restriction on the size of the problem that can be solved.
Answers: 1
Do you know the correct answer?
The goal of this assignment is to write a multithreaded program that explores synchronization challe...

Questions in other subjects:

Konu
Mathematics, 16.10.2020 22:01
Konu
Biology, 16.10.2020 22:01
Konu
Business, 16.10.2020 22:01
Konu
Mathematics, 16.10.2020 22:01