Windows下多线程程序如何获得多核的好处?有什么原则?(内有具体问题)

two_ears 2008-05-04 10:14:23
我原有的程序只是利用一个子线程,使用户操作界面可以持续响应。
但是考虑在单核CPU上运行仍会影响子线程的运算效率,所以在一个双核机器上运行了一下。
可是丝毫没有看到效果,反而好像慢了不少。(子线程的处理过程中有文件读写)
对此感到非常不理解,请专家帮忙分析一下?

另外,我想把子线程的处理分块,分成多个线程同步进行,想问一下都有什么需要注意的原则,比如粒度?
不知道intel提供的多线程库起到什么作用?我知道有一个开源的TBB,是吗?
...全文
167 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tjgao 2010-04-21
  • 打赏
  • 举报
回复
顶二楼个FEI啊,看个回答都要回复。
two_ears 2008-05-08
  • 打赏
  • 举报
回复
谢了啊:>
Intel_CG 2008-05-07
  • 打赏
  • 举报
回复
应该不会变慢,最多无加速。
two_ears 2008-05-05
  • 打赏
  • 举报
回复
只答一问呀,太扣了吧
呵呵
two_ears 2008-05-04
  • 打赏
  • 举报
回复
嗯,谢谢您的回答,TBB我已经下载了。
看来运用多核还要多学多尝试,呵呵。

想再多问一句,会不会有什么不良的设计,造成在多核机器上运行反而慢?
Intel_CG 2008-05-04
  • 打赏
  • 举报
回复

优化不是一个简单,单向的工作。减少粒度,会减少线程相互等待的时间,但会增加创建critical session的开销,对每个应用都需反复调试。

如果你不想花时间在调试上,TBB将是一个明智的选择,它帮你分配工作,调度线程,增加数据访问并发度。
two_ears 2008-05-04
  • 打赏
  • 举报
回复
哦,忘了,我们用的系统都是Windows XP。
对intel多核支持的怎么样?
MODERN OPERATING SYSTEMS THIRD EDITION The third edition of this book differs from the second edition in numerous ways. To start with, the chapters have been reordered to place the central material at the beginning. There is also now more of a focus on the operating system as the creator of abstractions. Chapter 1, which has been heavily updated, introduces all the concepts. Chapter 2 is about the abstraction of the CPU into multiple processes. Chapter 3 is about the abstraction of physical memory into address spaces (virtual memory). Chapter 4 is about the abstraction of the disk into files. Together, processes, virtual address spaces, and files are the key concepts that operating systems provide, so these chapters are now placed earlier than they previously had been. Chapter 1 has been heavily modified and updated in many places. For example, an introduction to the C programming language and the C run-time model is given for readers familiar only with Java. In Chapter 2, the discussion of threads has been revised and expanded reflecting their new importance. Among other things, there is now a section on IEEE standard Pthreads. Chapter 3, on memory management, has been reorganized to emphasize the idea that one of the key functions of an operating system is to provide the abstraction of a virtual address space for each process. Older material on memory management in batch systems has been removed, and the material on the implementation of paging has been updated to focus on the need to make it handle the larger address spaces now common and also the need for speed. Chapters 4-7 have been updated, with older material removed and some new material added. The sections on current research in these chapters have been rewritten from scratch. Many new problems and programming exercises have been added. Chapter 8 has been updated, including some material on multicore systems. A whole new section on virtualization technology, hypervisors, and virtual machines, has been added with VMware used as an example. Chapter 9 has been heavily revised and reorganized, with considerable new material on exploiting code bugs, malware, and defenses against them. Chapter 10, on Linux, is a revision of the old Chapter 10 (on UNIX and Linux). The focus is clearly on Linux now, with a great deal of new material. Chapter 11, on Windows Vista, is a major revision of the old Chap. 11 (on Windows 2000). It brings the treatment of Windows completely up to date. Chapter 12 is new. I felt that embedded operating systems, such as those found on cell phones and PDAs, are neglected in most textbooks, despite the fact that there are more of them out there than there are PCs and notebooks. This edition remedies this problem, with an extended discussion of Symbian OS, which is widely used on Smart Phones. Chapter 13, on operating system design, is largely unchanged from the second edition

567

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧