Multithreading – is it possible to execute a single threaded program on multiple CPU cores at the same time?

When I run a single threaded program I wrote on four core Intel, I can see in the windows task manager that all four cores of my CPU are actually more or less active One core is more active than others, but there are also activities No other programs (except the OS kernel, of course) run, which is reasonable for this activity When I shut down all activities of my program, all cores dropped to near zero What's left is a little "noise" at the core, so I'm sure all visible activities come directly or indirectly from my program (such as calling system routines)

Is it possible for the operating system or the kernel itself to try to balance some code or execution on all four cores, even if it is not a multithreaded program? Do you have any links to record this technology?

Some information about the program: it is a console application written in QT. The task manager declares that only one thread is running Maybe QT uses threads, but I don't use signals or slots, and I don't use any GUI

Screenshot of link to task manager: http://img97.imageshack.us/img97/6403/taskmanager.png

This problem has nothing to do with language and QT / C. I just want to know whether windows or Intel will balance single threaded code on all cores If they do, how does the technology work?

I can imagine that kernel routines such as reading from disk are arranged on all kernels, but this will not significantly improve performance, because the code still needs to run synchronously with kernel API calls

edit

Did you know that any tool can better analyze single threaded and / or multi-threaded programs than a poor Windows Task Manager?

Solution

A single threaded process can only run on a single core at any given time

But the operating system can migrate a thread from one core to another Although the operating system will try to keep the thread on the same kernel, if the last kernel running the thread is busy and the other kernel is idle, the operating system can migrate the thread

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>