ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > zstu-(2021-2022)-1 > student homework directories > 2019329621250_迟海滢 >
2019329621250-迟海滢-Homework-5 Version 0
👤 Author: by 2990994011qqcom 2021-10-29 07:17:17 last modified by 2990994011qqcom
For example, an account can only be logged in on one mobile phone, but two or more students want to log in to the same account at the same time, there will be data inconsistency.

Peterson's solution provides a good algorithmic descr iption of solving the critical-section problem and illustrates some of the complexities involved in designing software that addresses the requirements of mutual exclusion, progress, and bounded waiting.

solution:
Process Pi
do{
flag[i] = TRUE;
turn = j;
while(flag[j] && turn == j);
//CRITICAL SECTION
flag[i] = FALSE;
//REMAINDER SECTION
} while(TRUE);

Process Pj
do{
flag[j] = TRUE;
turn = i;
while(flag[i] && turn == i);
//CRITICAL SECTION
flag[i] = FALSE;
//REMAINDER SECTION
} while(TRUE);

Please login to reply. Login

Reversion History

Loading...
No reversions found.