多CPU编程的问题,高手请进
请问如何能将线程指定给某个CPU运行,因为我的计算机是多CPU的,为了控制我的线程运行,我需要将每一个线程指定给某个CPU运行,请问如何实现??? 问题点数:50、回复次数:8Top
1 楼Jarrylogin(正经事情我不会,歪门邪道样样行)回复于 2005-11-01 08:25:46 得分 0
不会,UP,学习中Top
2 楼zhxk(zhangxukun)回复于 2005-11-01 08:31:35 得分 0
从理论上和你讨论一下:)
CPU是操作系统管理的资源,用户程序只能使用不能控制,所以一般是不充许强制占用的
所以你只能开和cpu差不多的线程,这样操作系统会尽量让线程并发,这样也达到了你的目的了。
Top
3 楼oyljerry(【勇敢的心】→ ㊣提拉米苏√㊣)回复于 2005-11-01 15:04:16 得分 10
可以控制线程的运行Top
4 楼mct1025(malone)回复于 2005-11-01 16:07:41 得分 10
参考核心编程的线程亲缘性部分
应该可以限制线程在单个处理器上运行
我没有多CPU,没试过Top
5 楼DrSmart(斯玛特)回复于 2005-11-01 22:26:53 得分 10
windows核心编程中提到过,自己看看了Top
6 楼WuOu(天堂*蓝珀湖*仰音*诚彦)回复于 2005-11-02 11:14:29 得分 10
使用SetThreadAffinityMask和SetThreadIdealProcessor及其相关的函数.Top
7 楼wj59(wj59)回复于 2005-11-02 16:38:51 得分 10
You can use the GetSystemInfo function to determine the number of processors on the computer.
You can also use the GetProcessAffinityMask function to check the processors on which the thread is allowed to run.
Note that GetProcessAffinityMask returns a bit mask whereas SetThreadIdealProcessor uses an integer value to represent the processor.
Top
8 楼chensy0626(无可奈何)回复于 2005-11-02 23:17:43 得分 0
多些各位,我先试试,有结果后汇报Top




