当前位置:网站首页>The difference between spin and sleep

The difference between spin and sleep

2022-07-07 01:08:00 raoxiaoya

sleep: It is realized by timer , Thread will be suspended , Give up CPU, When the time comes, the operating system will change the thread to the ready state , And join the ready queue waiting to be scheduled .

The spin : It is generally used when robbing the lock , If you fail to grab the lock, spin a certain number of times , Spin operation will call CPU Of PAUSE Instructions .PAUSE Command to do nothing , But it will consume CPU Time , So I won't give up CPU.

原网站

版权声明
本文为[raoxiaoya]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207061722275668.html