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 10:40
"it security policy enforcement and monitoring" respond to the following: describe how monitoring worker activities can increase the security within organizations. describe the rationale that managers should use to determine the degree of monitoring that the organization should conduct. explain the extent to which you believe an organization has the right to monitor user actions and traffic. determine the actions organizations can take to mitigate the potential issues associated with monitoring user actions and traffic.
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
Creating "smart interfaces" in all sectors of industry, government, and the public arena is one of the fastest growing hct areas. these interfaces model, interpret, and analyze such human characteristics as speech, gesture, and vision. the field of biometrics, in which humans authenticate themselves to machines, is an area of considerable interest to hct practitioners. fingerprint scans are one of the most frequently used biometric options, and this article, biometric student identification: practical solutions for accountability & security in schools, makes a case for the implementation of fingerprint scans in schools. critique the article, and answer the following questions: according to the author, what are the main benefits of adopting fingerprint scans in schools for student identification? according to the author, what are the main drawbacks of adopting fingerprint scans in schools for student identification? do you agree with the author's assessment of the pl
Answers: 2
question
Computers and Technology, 23.06.2019 22:20
If i uninstall nba 2k 19 from my ps4 will my career be gone forever?
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
To maintain clarity and focus lighting might be needed
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, 02.04.2021 08:50
question
Biology, 02.04.2021 08:50
question
Mathematics, 02.04.2021 08:50
question
Mathematics, 02.04.2021 08:50
question
Computers and Technology, 02.04.2021 09:00
question
Mathematics, 02.04.2021 09:00
question
Mathematics, 02.04.2021 09:00
question
Mathematics, 02.04.2021 09:00
Questions on the website: 13722360