"Scalable Multithreaded Programming with Thread Pools" 阅读笔记
2010-12-23 15:28
651 查看
(MSDN Magzine 上的文章
)
"There are many different ways to distribute your work across multiple
cores. One of the easiest and most robust is called task-based
programming."
"To achieve this state of multicore bliss, you’ll have to reexamine some
of your preconceptions of how to attack a programming problem and
rethink them in terms of task-based programming."
There are a few guidelines to keep in mind when converting a large single-threaded job into multithreaded tasks:
The large job can be arbitrarily divided into 1 to n
tasks.
The tasks should be able to run in any order.
The tasks should be independent of each other.
The tasks must have associated context data.
to wantonly create and destroy them. There are not-insignificant costs
associated with creating and destroying a thread, so if you do this
constantly, it’s easy to lose any advantage you gain by multithreading."
"The advantage of using a thread pool instead of creating your own
threads is that the OS will take care of scheduling tasks for you—your
job will be to keep feeding tasks into the thread pool so that the OS
will be able to keep all of the hardware threads busy."
本来期待这篇文章能介绍 Thread Pool 的机制及调用建议, 结果往后面一看, 发现转到以快速排序为例子讲如何切分 task 去了, 没什么意思.
不过文章前面介绍基本原则的地方多少还是值得一看.
)
"There are many different ways to distribute your work across multiple
cores. One of the easiest and most robust is called task-based
programming."
"To achieve this state of multicore bliss, you’ll have to reexamine some
of your preconceptions of how to attack a programming problem and
rethink them in terms of task-based programming."
From Threads to Tasks
"There are a few guidelines to keep in mind when converting a large single-threaded job into multithreaded tasks:
The large job can be arbitrarily divided into 1 to n
tasks.
The tasks should be able to run in any order.
The tasks should be independent of each other.
The tasks must have associated context data.
Using the Thread Pool
"Threads require a lot of bookkeeping by the OS, so it’s not a good ideato wantonly create and destroy them. There are not-insignificant costs
associated with creating and destroying a thread, so if you do this
constantly, it’s easy to lose any advantage you gain by multithreading."
"The advantage of using a thread pool instead of creating your own
threads is that the OS will take care of scheduling tasks for you—your
job will be to keep feeding tasks into the thread pool so that the OS
will be able to keep all of the hardware threads busy."
本来期待这篇文章能介绍 Thread Pool 的机制及调用建议, 结果往后面一看, 发现转到以快速排序为例子讲如何切分 task 去了, 没什么意思.
不过文章前面介绍基本原则的地方多少还是值得一看.
相关文章推荐
- "Contracts and Interoperability A Conversation with Anders Hejlsberg, Part V" 阅读笔记
- "The Trouble with Checked Exceptions A Conversation with Anders Hejlsberg, Part II" 阅读笔记
- "Essential WPF - Chapter 8 Styles" 阅读笔记
- "Essential WPF - Chapter 5 Visuals" 阅读笔记
- "My History of Visual Studio" 阅读笔记
- "Essential WPF - Chapter 6 Data" 阅读笔记
- "The Design and Evolution of C++" 阅读笔记
- 关于Parallel & MultiThread Programming的一些总结
- “Multithreaded Job Queue”源码阅读笔记
- "Only the original thread that created a view hierarchy can touch its views"引发的思考_Handler的使用
- 解决"There is already an open DataReader associated with this Command which must be closed first."
- "虚拟校园"网络组件开发笔记
- Multi-Programming-5 Thread Pools
- "_OBJC_CLASS_$_OpenUDID", referenced from:&linker command failed with exit code 1 (use -v to see inv
- "current thread not owner"错误的解决方法
- "File not found""linker command failed with exit code 1" in Xcode 7.2.1
- extern "C" 阅读笔记 zz
- "Not associated with a trusted SQL Server connection"解决方法
- <Programming_in_Lua> 笔记(未完)
- "compileDebugJavaWithJavac"错误解决