Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The two atomic instructions while (turn!=0), and while (turn !=1); in thread 0 and thread 1 each takes 100 mu s (100 microseconds). The two

image text in transcribed

The two atomic instructions while (turn!=0), and while (turn !=1); in thread 0 and thread 1 each takes 100 mu s (100 microseconds). The two atomic instructions turn and turn = 1; and turn = 0; also each takes 100 mu s (100 microseconds) also. Critical region(); in both threads takes 1 ms (1 millisecond) each consisting of 4 atomic instructions cr1 cr2, cr3, and cr4 (none of these 4 can be stopped in the middle and switched to another thread). We also assume that each of crl, cr, 2 cr, 3 and cr4 takes the same amount of time or 1ms 4 250 mu s. Non_ciritcial_region(); in both threads take 2ms (two milliseconds) each consisting of 4 atomic instructions nc1 till nc4. We also assume each of nc1, nc2, nc3, and nc4 takes the same amount of time or 500 mu s. To clarify, one iteration in the while (TRUE) {...} of thread 0 running every instruction and function exactly once takes 100 mu s + 1ms 100 mu s + 2ms, or 3.3 ms. Suppose OS schedules by round robin of thread 0 for 2ms, thread 1 for 2ms, thread 0 for 2ms, and thread 1 for 2ms. Compute the real amount of time when OS moves between thread 0 and thread l each twice as above. Note the amount of time could be more than 8 ms since at the end of 2 ms, thread 0 may be in the middle of an atomic instruction. Show which instruction is being executed in thread 0 when thread 0 and thread l each has been executed twice with 2ms as the time of scheduling. Tabulate and show how much time is spent in each instruction of thread 0 in the first run and in the second run

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

Are all legal fees paid by a taxpayer deductible? Explain.

Answered: 1 week ago

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago