this post was submitted on 02 Jul 2023
420 points (96.9% liked)
Technology
58303 readers
22 users here now
This is a most excellent place for technology news and articles.
Our Rules
- Follow the lemmy.world rules.
- Only tech related content.
- Be excellent to each another!
- Mod approved content bots can post up to 10 articles per day.
- Threads asking for personal tech support may be deleted.
- Politics threads may be removed.
- No memes allowed as posts, OK to post as comments.
- Only approved bots from the list below, to ask if your bot can be added please contact us.
- Check for duplicates before posting, duplicates may be removed
Approved Bots
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
So what I want to know is why do we still have programs that run on a single core when nearly every Windows PC out there is running a multi-core processor?
What are we missing to have the OS adapt any program to take advantage of the hardware?
You can't automatically adapt that. Multi thread safe programming takes extra work (or certain languages or frameworks that are able to optimize this). And even then, not all types of tasks make sense to multithread.
The OS still does take advantage of multiple cores, though. You never have just one process running. The OS will schedule different processes on different cores.
To run something on multiple cores you need to detect a bunch of different tasks it is doing that don't depend on one another. Then you can execute each task in its own thread. The problem is that most often these different task don't exist, or, if they do, figuring them out automatically by the code is likely equivalent to solving the halting problem, that is it's undecidable and there can't exist a program that does this.
Multi-threaded programming is hard. You can't just write some code and expect it to work across 4 cores, you need to know what to parallelise and how to do it. If you think normal bugs are hard to fix, just wait until you have a calculation that gives a different answer each time you run it thanks to race conditions.