并行编程的任务分解模型 Task Decomposition

any concurrent algorithm is going to turn out to be nothing more than a collection of concurrent tasks.

  • be obvious independent function calls within the code
  • be loop iterations that can be executed in any order or simultaneously
  • be groups of sequential source lines that can be divided and grouped into independent computations.

 

常用的模式是:主进程定义和准备任务,分配给线程执行,等待所有线程执行完毕。

The most basic framework for doing concurrent work is to have the main or the process thread
define and prepare the tasks, launch the threads to execute their tasks, and then wait until all
the spawned threads have completed.

 

There are many variations on this theme…

任务分解中会遇到的问题和思考:

  • Are threads created and terminated for each portion of parallel execution within the application?
  • Could threads be put to “sleep” when the assigned tasks are finished and then “woken up” when new tasks are available?
  • Rather than blocking after the concurrent computations have launched, why not have the main thread take part in executing the set of tasks?
  • Implementing any of these is simply a matter of programming logic, but they still have the basic form of preparing tasks, getting threads to do tasks, and then making sure all tasks have been completed before going on to the next computation. Is there a case in which you don’t need to wait for the entire set of tasks to complete before going to the next phase of computation?
  • You may also encounter situations in which new tasks will be generated dynamically as the computation proceeds.

 

转载于:https://www.cnblogs.com/whos/archive/2010/09/07/1820517.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值