7

This is the reasoning for my question: I read this in a text book “Each CPU (or core) can be working on one process at a time.”

I'm assuming that this used to be accurate but is no longer fully true. How does multi threading play into this? Or is this still true, can a cpu core on linux still only work on one process at a time?

2 Answers 2

4

A single CPU handles one process at a time. But a "process" is a construct of an operating system; the OS calls playing a video in VLC a single process, but it's actually made up of lots of individual instructions. So it's not as if a CPU is tasked with playing a video and has to drop everything it was doing. A CPU can take on the task of playing a video → switch over to checking for keyboard or mouse input → draw some stuff on the screen → check to see if devices have been attached in any known port → and so on. All within the blink of an eye.

Modern computers excel at multi-tasking. This is why you can launch a video in VLC and have it play continuously even though your computer is doing 100 other odd jobs "at the same time".

3
  • It uses time slicing: the OS is woken up by an alarm ever so often, it then switches to a different thread/process/task. Feb 17, 2017 at 16:29
  • Should SMT ("hyperthreading") be considered running several tasks simultaneously on a single core? Also, perhaps it would be best to rephrase to say "core" instead of "CPU"?
    – dhag
    Feb 17, 2017 at 17:40
  • Each time the CPU switches tasks (e.g. from displaying a video frame to updating mouse position) there is the risk that all or part of the CPU caches do get dropped, though. Just like you or I can only hold several digits in our working memory at once, so is it with microprocessors (although they can remember many more digits than we can). Apr 14, 2023 at 12:04
-1

I believe that a single threaded process (program) will be constrained to execution on a single CPU core even if its running on a system with a multi-core CPU.
If a processes is multithreaded and its running on a system with a multi-core CPU, the execution of individual threads can be handed off to different CPU cores and therefore the program can benefit from parallel processing.
I think when muliti-core CPU's first appeared in the early 2000's alot of programs still had a single threaded architecture and therefore saw no performance benefit from the muliti-core CPU's.
Although the system overall could benefit as it could run other processes on the the other CPU cores.

1
  • 2
    This is the answer to the opposite question “can a single thread run over many cores?” not “can a single core run may threads?” Feb 17, 2017 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .