📄 33.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif;} a.at-term { font-style: italic; } </style> <title>OpenMP Synchronization Constructs</title> <meta name="Generator" content="ATutor"> <meta name="Keywords" content=""></head><body> <p>In a shared memory environment, accesses by multiple threads to shared variables (memory locations) must often be coordinated to ensure correct results. For
example, if one thread is writing a value at a location while others are reading from it, then the result of the read is (at best) ambiguous: it depends on whether the write succeeded before or after the read. Given that there is no inherent synchronization of threads, this situation, known as a <em>data race condition</em>,
typically leads to results that vary from run to run. (Note that this problem arises only in situations where at least one thread is writing to the memory location; if all are simply reading there is no conflict.) </p>
<p>OpenMP provides a number of constructs for thread synchronization and coordination. Here we will discuss the most important of these: </p>
<ul>
<li>
<p>critical </p>
</li>
<li>
<p>atomic </p>
</li>
<li>
<p>barrier </p>
</li>
<li>
<p>master </p>
</li>
</ul>
<p>These are sufficient for many needs, but OpenMP also provides a set of runtime thread locking functions which can be used for fine control. </p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -