Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question -1 Consider thread functions A, B, C, D, E, F, and G. We need to ensure the following execution constraints for them: A and

Question -1

Consider thread functions A, B, C, D, E, F, and G. We need to ensure the following execution constraints for them:

A and B have to execute mutual exclusively

A has to execute after C

B has to execute after D

E has to execute after A or B F has to execute after A and B

G has to execute after A or B

The following are the rules for naming and using the locks.:-

You should use as low a number of locks as possible

The names of the locks should have a leading letter L and numbered consecutively starting from 1, e.g., L1, L2,

Put your synchronization solutions for thread functions in the order from A to F. Whenever you need to use a new lock, you should use the lowest number first. For example, if you need to use a new lock for thread function D, and only L1 and L2 are in use in the previous thread funcitons A to C, then use L3.

For each lock, you can use lock and unlock calls, but put no space for them. For example, lock(L3); unlock(L2); ...

Whenever there is no impact, you need to put the lock/unlock calls in alphabetical order of the lock numbers. For example, unlock(L1); unlock(L3): instread of unlock(L3): unlock(L1): if there is no specific order requirement.

When the order of the lock/'unlock calls do matter, you should obey the necessary order for proper synchronization.

Do not perform unnecessary lock and unlock, only those required for enforcing correct synchronization.

Remember these rules so that you can skip reading the same rules during the exam.

A) What is the minimal number of locks needed to synchronize all threads following the constraints?

B) Give the synchronization solution for each thread function

For A:

For B:

For C.

For D:

For E:

For F:

For G:

For each synchronization solution above, put the statements (lock and unlock calls and the thread function name) in proper execution order with a single space as the separator. Each statement should end with a semicolumn. For example:

lock(L2); lock(L3); C; lock(L1); unlock(L2); unlock(L5);

QUESTION 2:-

Use the following letters to label the values of a lock.

U: represents unlocked

L: represents locked

What should be the initialization values for the locks you used in the previous question?

Initialization value for L1?

Initialization value for L2?

QUESTION 3:-

Consider the same thread functions as Question 2 with the same constraints.

A and B have to execute mutual exclusively

A has to execute after C

B has to execute after D

E has to execute after A or B

F has to execute after A and B

G has to execute after A or B

What is the minimal number of integer semaphores that are required to assure the desired synchronization?

What is the minimal number of binary semaphores that are required to assure the desired synchronization?

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

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

=+ How does the intent of the several policies differ?

Answered: 1 week ago