开发者

C Language Program Compiled Will it use multicore cpu?

开发者 https://www.devze.com 2023-04-12 06:54 出处:网络
Platform: Windows XP Processor : Dual Core I have a progr开发者_如何学运维am written in C Language which is compiled and its exe is formed.

Platform: Windows XP Processor : Dual Core

I have a progr开发者_如何学运维am written in C Language which is compiled and its exe is formed. My question is that will the program use both the Cores (since my machine is dual core) or I have to make my program multithreaded in order to do it ?


You have to implement a multithreaded program when you want to use multiple cores.

There are plenty of threading libraries out there. I'd recommend you have a look into OpenMP website, which is quite easy to integrate and use for parallization.

EDIT: a simple example:

Normally you can parallelize your for loops simply by adding:

#pragma omp parallel
for(...)

Of course, you have to link against OpenMP and compile with OpenMP support.


short answer: you have to make your program multithreaded in order to make use of both cores.


a single processor at a time can execute only one program. so u need to create a thread and execcute both at the same time to use the dual core.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号