ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU-(2020-2021)-1 > student homework > 2018329621072_陈怡 >
homework5_陈怡_2018329621072 Version 0
👤 Author: by 1210775967qqcom 2020-11-02 14:18:09
In real life, we may encounter the problem that "more than one person wants to use the same resource". For example: in the classroom, there is only one computer, many people want to use it. The natural solution is to stand in line next to the computer. After the first person uses, the second person uses again.

To slove this problem in program, we need all the persons who want to use the computer to wait a signal that represents the computer available.

// For each person that want to uses the computer

while(true){

wait(available);  // until the computer is available. set the computer unavailable.

// critical section

signal(available);  // give an available signal.

// remainder section

}

 

Please login to reply. Login

Reversion History

Loading...
No reversions found.