Answers for "dining philosophers problem deadlock"

0

dining philosophers problem deadlock

while(TRUE) 
{
    wait(stick[i]);
    /* 
        mod is used because if i=5, next 
        chopstick is 1 (dining table is circular)
    */
    wait(stick[(i+1) % 5]);  
                    
    /* eat */
    signal(stick[i]);
    
    signal(stick[(i+1) % 5]); 
    /* think */
}
Posted by: Guest on October-14-2020

Python Answers by Framework

Browse Popular Code Answers by Language