Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question pertains to Multithreading Class X holds a data buffer, and has SYNCHRONIZED methods C (for consuming from buffer) and S(for supplying to buffer).

This question pertains to Multithreading

Class X holds a data buffer, and has SYNCHRONIZED methods C (for consuming from buffer) and S(for supplying to buffer). Consider an instance xinstance of Class X, consumer threads T1 and T2, and supplier thread T3, and the following sequence of actions on xinstance:

Thread T1 enters method C, and at a certain point issues wait(), since T3 has NOT supplied it yet

Subsequently, thread T2 enters method C, and at some point issues a wait(), because T3 has NOT supplied it yet.

LASTLY, throad T3 enters method S, and fills in the supply, as well as issuing a notifyAll(), which finishes and exits S

Assume that T3's supply is sufficient for only ONE of the consumers, and that after T3 is finished executing S as shown above, it will be terminated (will not return to S again)

However, T1 and T2 are insatiable and will want to keep coming back to method C for more. Assume that there is no attempt by the application to SAFELY terminate either T1 or T2, which means they are allowed to continue running.

Describe one possible sequence of thread stats that T1 and T2 might go through, starting from the time they issue a wait(), up to the time when they cannot issue any more state changes.

Assume there is another state, "RUNNING" for when a thread is executing on the CPU.

For each state change of T1 and T2, specifcy the cause of change of the state.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

b. If n is even, let F = 0.5n, 0.5n + 1,, 0, 1,, 0.5n 1 / n.

Answered: 1 week ago