Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following coroutines (two threads executing concurrently on a single CPU). Because CPU can only execute one instruction at a time, the instructions from

Consider the following coroutines (two threads executing concurrently on a single CPU). Because CPU can only execute one instruction at a time, the instructions from the two threads are interleaved with each other (in some arbitrary order).

boolean[] flag = {false, false};

P0: P1:

while (flag[1]) while (flag[0])

busy-waiting; busy-waiting;

flag[0] = true; flag[1] = true;

enter critical-section; enter critical-section;

do critical-section work; do critical-section work;

exit critical-section; exit critical-section;

flag[0] = false; flag[1] = false;

All questions in this part pertain to above coroutines and are T / F; mark your answers clearly!

  1. If process P1 dies before entering the critical section, then process P0 may get prevented from entering the critical section indefinitely.

TRUE FALSE

  1. If P0 enters critical section and then gets terminated while still inside of critical section, then process P1 will definitely be prevented from entering the critical section.

TRUE FALSE

  1. The Boolean array flag[] and the overall implementation of P0 and P1 guarantees mutual exclusion, i.e., these two coroutines cannot both be inside the critical section at the same time.

TRUE FALSE

  1. It is not possible that, during some execution sequence of P0 and P1, both values flag[i] = true at the same time (for i = 0, 1).

TRUE FALSE

  1. If P0 and P1 execute at approximately the same speed and the OS context-switches between the two threads with fairness, then it will be guaranteed that P0 and P1 wont be inside the critical section at the same time.

TRUE FALSE

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions