Non-Blocking Algorithm - Introduction

hellwolf 2008-11-30 11:14:50
原文: http://blog.chinaunix.net/u/8057/showart_1672481.html

Non-Blocking Algorithm - Introduction

Author: ZC Miao <hellwolf.misty át gmail dôt com>

Date: Saturday, November 29 2008

In computer science, non-blocking synchronization ensures that threads competing for a shared resource do not have their execution indefinitely postponed by mutual exclusion. A non-blocking algorithm is lock-free if there is guaranteed system-wide progress; wait-free if there is also guaranteed per-thread progress1.

This simple diagram shows more clearly the idea:

+------------------------------+--------------------------------+
| | |
| Mutual Exclusion | Non-Blocking |
| | |
| | +-------------------------+ |
| | | | | | |
| | H | | | Lock-Freedom | |
| | y | | | | |
| | b | | | +------------------+ | |
| Blocking | r | Busy-Waiting| | | | | |
| | i | (Polling) | | | Wait-Freedom | | |
| | d | | | | | | |
| | s | | | +------------------+ | |
| | | | | | |
| | +-------------------------+ |
| | |
+------------------------------+--------------------------------+

Using mutual exclusion is the most instinctive and easiest way to protect data from corruption in concurrent multi-threaded programming, which simply creates a critical region around the operations of data structure. It works fine most of the situations, but in some situations, lock is just too expensive or even not available. One example is for some ISR(Interrupt Service Routines), if it disables the interruption, then the scheduler will not be run until they open the interruption again, if it also waits for some resources which is hold by some task, then it will never available because scheduler stops. Another example is in RTOS, higher priority wait for the lower priority task to release the resource, then it causes priority-inversion. So, non-blocking algorithms are born to solve these problem without using mutual exclusions.

Valois published his most cited paper talking about lock-free data structure at 19952. But unfortunately, there are some mistakes with the memory management method introduced by Valois3.

But algorithms from Valois needs special memory management, and it's just too complicated to use. Michael and Scott published their own algorithms based on the idea of cooperative task from Valois4.

There's another more detailed notes on lock-free and wait-free algorithms area from Internet5.

1. Non-blocking synchronization from Wikipedia http://en.wikipedia.org/wiki/Lock-free_and_wait-free_algorithms#Wait-freedom

2. J.D. Valois, Lock-Free Data Structures PhD Thesis, Rensselaer Polytechnic Institute, Department of Computer Science, 1995.

3. Maged M. Michael, Michael L. Scott Correction of a Memory Management Method for Lock-Free Data Structures, Department of Computer Science University of Rochester, 1995.

4. Maged M. Michael Michael L. Scott, Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms,, Department of Computer Science University of Rochester, 1995.

5. Some notes on lock-free and wait-free algorithms http://www.audiomulch.com/~rossb/code/lockfree
...全文
333 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Super.Jiju 2008-12-05
  • 打赏
  • 举报
回复
niubility
hmsuccess 2008-12-05
  • 打赏
  • 举报
回复
mark
hellwolf 2008-12-05
  • 打赏
  • 举报
回复
Update:
原文: http://blog.chinaunix.net/u/8057/showart_1672481.html

Non-Blocking Algorithm - Introduction

Author: ZC Miao <hellwolf d o t misty a,t gmail d o t com>

Revision:

* 2008-12-04

Add revision information.
* 2008-11-29

First revision.

Non-Blocking Algorithm Introduction

In computer science, non-blocking synchronization ensures that threads competing for a shared resource do not have their execution indefinitely postponed by mutual exclusion. A non-blocking algorithm is lock-free if there is guaranteed system-wide progress; wait-free if there is also guaranteed per-thread progress1.

This simple diagram shows more clearly the idea:

+------------------------------+--------------------------------+
| | |
| Mutual Exclusion | Non-Blocking |
| | |
| | +-------------------------+ |
| | | | | | |
| | H | | | Lock-Freedom | |
| | y | | | | |
| | b | | | +------------------+ | |
| Blocking | r | Busy-Waiting| | | | | |
| | i | (Polling) | | | Wait-Freedom | | |
| | d | | | | | | |
| | s | | | +------------------+ | |
| | | | | | |
| | +-------------------------+ |
| | |
+------------------------------+--------------------------------+

Using mutual exclusion is the most instinctive and easiest way to protect data from corruption in concurrent multi-threaded programming, which simply creates a critical region around the operations of data structure. It works fine most of the situations, but in some situations, lock is just too expensive or even not available. One example is for some ISR(Interrupt Service Routines), if it disables the interruption, then the scheduler will not be run until they open the interruption again, if it also waits for some resources which is hold by some task, then it will never available because scheduler stops. Another example is in RTOS, higher priority wait for the lower priority task to release the resource, then it causes priority-inversion. So, non-blocking algorithms are born to solve these problem without using mutual exclusions.

Valois published his most cited paper talking about lock-free data structure at 19952. But unfortunately, there are some mistakes with the memory management method introduced by Valois3.

But algorithms from Valois needs special memory management, and it's just too complicated to use. Michael and Scott published their own algorithms based on the idea of cooperative task from Valois4.

There's another more detailed notes on lock-free and wait-free algorithms area from Internet5.

1. Non-blocking synchronization from Wikipedia http://en.wikipedia.org/wiki/Lock-free_and_wait-free_algorithms#Wait-freedom

2. J.D. Valois, Lock-Free Data Structures PhD Thesis, Rensselaer Polytechnic Institute, Department of Computer Science, 1995.

3. Maged M. Michael, Michael L. Scott Correction of a Memory Management Method for Lock-Free Data Structures, Department of Computer Science University of Rochester, 1995.

4. Maged M. Michael Michael L. Scott, Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms,, Department of Computer Science University of Rochester, 1995.

5. Some notes on lock-free and wait-free algorithms http://www.audiomulch.com/~rossb/code/lockfree
hityct1 2008-12-01
  • 打赏
  • 举报
回复
mark
内容概要:本文针对考虑算力负荷时空迁移特性的多微电网与共享储能系统的协同优化调度问题展开研究,并提供了完整的Matlab代码实现。研究构建了融合算力负荷动态迁移特征的数学优化模型,通过引入共享储能机制,实现多微电网间的能量互济与资源协同,有效提升系统对分布式能源波动性和负荷不确定性的适应能力。文中采用先进的优化算法求解该调度模型,重点解决了算力任务在时空维度上的灵活调配与电力供需平衡之间的耦合关系,旨在提高综合能源系统的运行经济性、可靠性与灵活性。所提出的方法为未来能源互联网背景下电-算协同管理提供了理论支持与技术路径。; 适合人群:具备电力系统分析、优化理论基础及Matlab编程能力的科研人员、高校研究生,尤其适用于从事微电网运行、共享储能配置、综合能源系统优化以及电-算融合等领域研究的专业技术人员。; 使用场景及目标:①开展多微电网与共享储能系统的协同调度策略设计与仿真验证;②支撑高比例可再生能源接入下的新型电力系统优化运行研究;③为考虑算力迁移的数据中心与电网协同调度提供建模与算法参考;④作为高水平学术论文撰写或学位课题研究的技术支撑与代码复现平台。; 阅读建议:建议读者结合Matlab代码与相关学术文献深入研读,重点关注目标函数构建、约束条件设定及求解器调用逻辑,可在现有模型基础上拓展多时间尺度优化、不确定性建模(如鲁棒优化、随机规划)或加入实际工程约束进行二次开发与深化研究。

33,025

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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