Threads are the devil. Never -lpthreads if you know what's good for you. Threads were introduced to our code by Russian agents trying to subvert the productivity of American programmers in the cold war. Spawning a thread is the single worst thing your program can do. Say no to threads. Friends don't let friends use threads. Don't fucking use threads!
Run this command:
grep '^processor' /proc/cpuinfo | wc -l
That is the number of things your computer is capable of doing at once. Now run this command:
ps aux | wc -l
This is the number of things your computer is trying to do at once right now.
Threads are not magic, they can't make your computer do more things at once than it's capable of. Who would you rather be in charge of scheduling: preemption, which will take control away at random times, including in the middle of writes; or your code? Say no to threads. Design your code like a fucking adult.
@sir weird take, but OK.
@sir Use message queues to communicate between hardware threads. Implemented however you need: lightweight POSIX threads, properly isolated processes, keeping the queues in shared memory, or processes running on different machines. The implementation doesn't really matter, as long as you aren't reinventing the wheel^Wlow-level synchronization primitives.
And also, consider liburcu for data-structures, libuv for work queues, and libczmq for the framing.
@sir NULL-pointer as such is not the problem — it's just `option` wrapper. Letting the programmer access the value without pattern-matching first — that's one of the things wrong with C.
@amiloradovsky I am familiar with the null "problem". Threads are way, way, way, way worse.
@sir There is no way to escape them in general — shared-memory parallelism needs to be utilized somehow. And the processes are somewhat heavier.
OTOH, threads are PITA. — One should try to avoid them at first.
@amiloradovsky no to all of that
@sir 🙂 SMP is fundamentally wrong or what?
@amiloradovsky that's not what I said
@sir now run
ps aux without piping it to
see all those processes with
S? those processes aren't running right now, but could potentially run later
see any processes with
Z? those processes don't even exist. they're just placeholders to make sure the process IDs don't get reused until the parent process acknowledges that they finished
see any processes with
X? something is wrong with your computer
@ben s/wrong with your computer/wrong with Linux/
s/wrong with Linux/wrong with Unix/
s/wrong with Unix/wrong with your computer/
@sir if you can see a process in
X state, that means your computer is showing you a process that's already exited and been cleaned up
@sir Type this command to get the number of threads that you as a programer can easily manage:
@sir 4 / 271 😞 ... I guess your ratio is much better with your setup using alpine (no systemd) and no DE?
@sir Yes, let's switch back to cooperative multitasking
@sir ok since you won't pay me to explain why you're a transphobic bigot, at least tell me why context switching, especially a method that keeps one thing from taking down the whole system, isn't worth the completely reasonable overhead cost
@anna this post wasn't arguing against context switching in general, and especially not arguing against context switching as a means for the kernel to keep your userspace programs in check, but rather against the idea that preemptive multitasking somehow can magically make your program "do two things at once"
@anna and since your program is just going to do one thing at a time anyway, planning the scheduling of tasks yourself is a much more reliable solution than letting the kernel switch between your tasks effectively at random
@anna for additional access to my expertise on preemptive multitasking please subscribe to my patreon
@sir your answer is dumb and you still havent paid off your debt, especially since we TRIED cooperative multitasking and it was buggy and crashy as hell. "just write good code " isnt an answer to that, because nobody is going to do that shit, and especially in the year of our dark lady two thousand twenty, some bug in the newest bullshit web framework of the week that everyone is using taking down people's wholeass computers on a twice a week basis sounds like a nightmare
@anna can't wait for the next random post in my history you dig up to write a nonsensical rant about
@sir its pinned to the top of your profile, brain genious
@anna you still had to come back to my profile two hours later to find it 😉
@sir oh wow i had to get up from the computer for a while and also do some work wow cool dude you sure pwned me 🙄
if you must know kaniini said you are "not a bad person" so i was going to see if you had anything worthwhile to say about anything and just. pinned. right there.
@anna I stopped taking you seriously a while ago, now I'm just trying to get a rise out of you every time you post
@birb @sir we dont got time to explain basic-ass "how to not be a transphobic piece of shit 101" to everyone that comes along, maybe instead of blaming people who gave him that free education, blame him for wanting to have an argument like a little pissant instead of accepting that maybe the multiple trans people who have laid out in detail why this shit sucks ass know more about this than him
@steph yes, this is a take on shared memory mulititasking
@steph I think event loops or coroutines are the way to go
@steph coroutines can share memory without any ill consequences, or at least 100x more so than preemptive multitasking. Message passing and memory isolation are only necessary for preemptive multitasking or multiprocessing
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!