3 ms·
I’ve been studying pg’s Bel: http://paulgraham.com/bel.html http://paulgraham.com/bel.html It has a delightful idea: to ensure the current thread isn’t preempt
by sillysaurusx 6y ago
I’ve been studying pg’s Bel: http://paulgraham.com/bel.html http://paulgraham.com/bel.html
It has a delightful idea: to ensure the current thread isn’t preempted, set a global “lock” variable to true.
The scheduler checks “lock”. If it’s true, the current thread is added to the front of the threads list. Otherwise it’s added to the back.
Then the scheduler runs the first thread in the threads list.
So by setting “lock” to true, you are essentially instructing the scheduler never to switch threads.
- hedora 6y agoHow does that help if you have multiple cores?