News for hackers. Stuff that matters.
Re:An Introduction to Lock-Free Programming (2012) by brianberns on Sunday December 20, 2020 @07:12PM (#25490850)
> your worst enemy could simply never schedule that thread again

That seems too extreme to me. If the scheduler itself is potentially malicious, then no multi-threaded implementation is safe, since we can't assume that any thread we start will ever actually run.

Re:An Introduction to Lock-Free Programming (2012) by johnbender on Sunday December 20, 2020 @10:04PM (#25491769)
This is an important observation!

If the properties of concern for your thread or program are only safety properties (“never does a bad thing”) then the fact that the program may never do anything at all is just fine!

Then, if you want some liveness properties (“eventually does something good”) you’ll need to embed some assumption about fairness/scheduling/progress just as you’ve said!

This appears in early concurrency literature (TLA etc which I can’t be bothered to look for)

Re:An Introduction to Lock-Free Programming (2012) by manicdee on Sunday December 20, 2020 @08:03PM (#25491107)
This isn’t about malice.

Remembering that you are your own worst enemy, what this implies is that some other perfectly sane decision you made in the past has come to bite you in the arse.

Re:An Introduction to Lock-Free Programming (2012) by thmt on Monday December 21, 2020 @02:40AM (#25492904)
Alistarh et al. (https://arxiv.org/abs/1311.3200) show that assuming we have a kinder, non-malicious scheduler, the situation looks even better: lock-free (some process can make progress) algorithms have a stronger progress property of being wait-free (every process can make progress).

As omazurov mentioned as a top-level comment, threads can also die, which is rather like never being scheduled. In practice, I suspect that you're right that it's often too extreme of a model—many programs use locks and don't worry too much about this issue.

Re:An Introduction to Lock-Free Programming (2012) by colanderman on Sunday December 20, 2020 @07:47PM (#25491021)
"Malice" doesn't need to come into play. A thread could simply be waiting in line behind a non-preemptible thread which does not relinquish the CPU due to a bug.
Re:An Introduction to Lock-Free Programming (2012) by nyanpasu64 on Monday December 21, 2020 @12:31AM (#25492369)
One real-world example is assuming that the audio thread (scheduled at realtime priority if possible) is guaranteed to run, while the GUI thread may or may not run, or get descheduled at any point. Even if the GUI thread locks up (for example the user is resizing the window), the audio thread should not stop producing sound.
Re:An Introduction to Lock-Free Programming (2012) by insulanus on Sunday December 20, 2020 @07:52PM (#25491046)
"your worst enemy" can be a stand-in for "a faulty algorithm running on another thread".

Or, another way to look at it - a lock-free algorithm that allows starvation or livelock/deadlock.

Re:An Introduction to Lock-Free Programming (2012) by jganetsk on Sunday December 20, 2020 @07:48PM (#25491025)
It assumes that at least 1 thread is running at all times. There are algorithms that can make progress this way.
Re:An Introduction to Lock-Free Programming (2012) by read_if_gay_ on Sunday December 20, 2020 @07:41PM (#25490987)
A thread that never ran can’t lock up, so I guess it’s still technically lock free?
Re:An Introduction to Lock-Free Programming (2012) by brianberns on Sunday December 20, 2020 @07:44PM (#25490998)
Yes, it’s lock-free, but it doesn’t actually work.