subject

Now, we continue from Question 4 above. Before making his final decision on whether to use multi-threading or single-threading, the team leader asked you to show him a demonstration about how the multiple threads will be synchronized (so we completely ignore anything related to Round-Robin scheduling or time quantum here). You decided to implement 4 threads and divide the array into 4 sections. Thread T1 searches the first quarter (index 0 to 2,249,999), thread T2 searches the second quarter (index 2,500,000 to 4,999,999), thread T3 searches the third quarter (index 5,000,000 to 7,499,999) and thread T4 searches the last quarter (index 7,500,000 to 9,999,999. Thus, every thread knows its quarter and runs independently from the other threads.
When a thread T1...T4 has finished searching its quarter, successfully or unsuccessfully, it sets its state to finish using the boolean array finishRequest[i], where i = 1,...,4, and waits until the application, through its main thread T0, sends it a signal to terminate. However, if the search is successful, then this tread must inform all other threads immediately, and so the other threads consequently just terminate their searches, set their state to finish, using the boolean array finishRequest[i], and wait for a signal from the main thread, T0, to terminate. Once all 4 threads have terminated, the main thread, T0, can finally terminate.
Using Semaphores or Monitors, Write the synchronization code (You are NOT required to (and should not) write actual Java code for the solution; rather you need to write the solution using semaphore/monitor pseudo-code notation, and structures such as if, while, ... if necessary). In particular, you need to write the code for thread To and for threads T1, T2, T3 and T4. Use the following data structures and layouts for T0 and T1... T4 as given below.

→ It is better that you write the code of Ti...T4 using one single method that takes the thread ID as a parameter. However, if you wish, you are allowed to give the code of these 4 threads separately as well (i. e., in that case you will give the code of 5 different methods for each of the 5 threads).
// Shared data structures, you need to add other constructs as needed
// Initialize the state of all threads to not finished.
// A thread TT4 sets finishRequest[i] to true when it needs to terminate.
boolean finishRequest[n] = {false}; // All initialized to false here

T(0)
{
... // This is what you need to fill for T, code
}
T(int tid ) // tid is 1...4
{
... // This is what you need to fill for T, to T code
...// Again, if you wish, you can write 4 separate methods; one for each of the 4 threads
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:20
In what kind of attack can attackers make use of millions of computers under their control in an attack against a single server or network availability confidentiality integrity identity automated attack software? those who wrongfully disclose individually identifiable health information can be fined up to what amount per calendar year? single most expensive malicious attack hipaa what are script kiddies? advanced persistent threat security manager security engineer what level of security access should a computer user have to do their job what process describes using technology as a basis for controlling the access and usage of sensitive data? cybercriminal
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Awell-diversified portfolio needs about 20-25 stocks from different categories is this true or false?
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
To check whether your writing is clear , you can
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
You know the right answer?
Now, we continue from Question 4 above. Before making his final decision on whether to use multi-thr...
Questions
question
Mathematics, 06.11.2019 03:31
question
Mathematics, 06.11.2019 03:31
question
Mathematics, 06.11.2019 03:31
question
Mathematics, 06.11.2019 03:31
Questions on the website: 13722361