-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use fair spinlocks in SMP #1488
Comments
Most fair spinlock algorithms try to maintain FIFO spinlock access. I would think for a real time system, priority based access would lead to better control over response latencies. |
Yes that was the point about my comment in the other thread, i.e context switching overheads entering critical section ; there is something like the Lamport algorithm if I remember well. @patacongo for some references; an interesting usage of ticket spinlocks within linux kernel ; https://github.com/drouyang/pmtlock |
Hello. I try to implement fair spinlock and put on this.
But I only test on RR scheduler and I am not sure my implementation is correct or not. I have two questions:
So I hope I can get some suggestions from community. PS. I did't consider preemptive for this fair spinlock. |
I have read this paper. |
You could overlay priority groups, you'd need just not to use the builtin list + having something timeout-able because you'd need a time-slicing mechanism (e.g enforcing preemption and maintaining order) but it is tricky to achieve within a SCHED_RR policy. |
The spinlock implementation is very simple. Each CPU simply tries to acquire the spinlock via a test and set atomic operation, the first CPU to successfully perform the test and set is the "winner" and gets the spinlock. That CPU is complete arbitrary and not managed in any way.
This kind of spinlock can have adverse effects in SMP because under certain conditions other CPUs may always get the spinlock and one CPU can randomly be delayed for a significant amount of time.
We should consider replacing a fair spinlock implementation that enforces first-in, first out spinlocks. There are several fair spinlock algorithms. Some established and in common use, some simple and some complex, some straight-forward and some more controversial, some have undesirable side-effects. A first step would be to decide on an appropriate fair spinlock algorithm.
The text was updated successfully, but these errors were encountered: