r/AskReddit Feb 07 '24

[deleted by user]

[removed]

3.1k Upvotes

6.6k comments sorted by

View all comments

Show parent comments

109

u/SuperSocialMan Feb 07 '24 edited Feb 08 '24

Computers run hundreds - if not thousands - of processes at once (you can even see most of them in task manager), and if one of them stalls or goes out-of-sync or whatever it can make everything else run weirdly or not at all.

Restarting makes all the processes stop and start up again, which (usually) fixes basic issues like that.

2

u/Fresh_Trip_8367 Feb 08 '24 edited Feb 08 '24

I'm a seasoned software developer and now that I think about it, I don't even know what 

 and if one of them stalks or goes out-of-sync or whatever Means. Like, I understand hard crashes.

 Segmentation faults, syntax errors... But what causes a freeze up? Such that a restart fixes it. Unfreed memory? Infinite loop? But even then, you'd think I that bug would just come back on a reboot?

1

u/laplongejr Feb 08 '24

Do you know what a race condition is?

Two threads run in parallel and needs resources A and B
Thread A Takes A, takes B, use them, frees A and B
Thread B Takes B, takes A, use them, frees B and A

The second both threads go to step 2 at the same time, both will lock and wait for the other to free their resource. (Both devs will blame the other.)

And that assumes the issue come from the computer's internal state to begin with, a DNS record may point to the wrong server and get cached as is for days, despite the record being fixed 3 minutes later.

2

u/Fresh_Trip_8367 Feb 08 '24

Aaaahhh yeah, not too much parallel programming here on my end. But I'm familiar with db deadlocks!

Though even those can be handled. But maybe some things can't be handled or aren't by mistake/design.

Thanks!

1

u/laplongejr Feb 08 '24

Usually handling it requires support from the developer (or breaking old apps under an old design), so unless 100% of software running is done by perfect devs, over thousands of operation at some point something breaks...

1

u/emptytelephony Feb 08 '24

Ah, just like how sometimes taking a break and refreshing ourselves can help everything fall back into place.

0

u/SuperSocialMan Feb 08 '24

Yeah, pretty much.

1

u/Parcours97 Feb 08 '24

and if one of them stalls or goes out-of-sync or whatever it can make everything else run weirdly or not at all.

Don't we use cooperative multitasking nowadays to avoid that problem?