Semaphore solve writers & readers priority Priority & Fair Competition (reader writer)

Let me talk about the issue:

Here are the pseudo-random rand. Solving is also very simple, srand can. Content too lazy to change the ~ ~

Description and ideas:

 


 

 


 

 


 

 


 

 


 

Code:

 


 

 


 

 


 

 


 

 


 

operation result:

 


 

Readers priority:

 


 

 


 

 


 

 


 

 


 

Renderings:

 


 

 


 

fair competition:

Only readers who write thread made some changes. Increase the amount of signal que. sem_init (& que, 0,1).


 

 


 

effect:

 

Guess you like

Origin www.cnblogs.com/lqerio/p/11117657.html