Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following has been proposed as a \"solution\" to thecritical section problem

ID: 3617208 • Letter: T

Question

The following has been proposed as a "solution" to thecritical section problem for two processes, P0 and P1.    global intflag[2] = {0,0};    Enter CS(intprocess) {    do {       flag[process] = 1 - flag[1-process];    } while(flag[1-process] != 0)    Leave CS(intprocess) {       flag[process] = 0;    }    Does this "solution" satisfy therequirement of a solution to the critical section problem?    Justify your answer.
The following has been proposed as a "solution" to thecritical section problem for two processes, P0 and P1.    global intflag[2] = {0,0};    Enter CS(intprocess) {    do {       flag[process] = 1 - flag[1-process];    } while(flag[1-process] != 0)    Leave CS(intprocess) {       flag[process] = 0;    }    Does this "solution" satisfy therequirement of a solution to the critical section problem?    Justify your answer.

Explanation / Answer

I assume when flag is 1, that process is in it's criticalsection? I would think this solves CS. It seems like what you're saying iscorrect. You have 2 processes so here is a truth table showingyou. Process 1 Process 2 Process 1 Process 2 Flag 0 1 0 0 P1 ok for CS? No - Yes - P2 ok for CS? - Yes - Yes This covers both conditions which can apply to this code. P1 and P2both being 1 shouldn't be an issue because processes won't start intheir CS. And P1 = 1 and P2 = 0 is handled the same way asthe first 2 columns. Just plug in the only 2 sequencespossible and it should be easy. The only issue is with 0,0. Itseems if you start with no process in it's critical section, noprocess is allowed to enter it's critical section.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote