<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>http://wiki.foofun.cn//index.php?action=history&amp;feed=atom&amp;title=Blocking_Process</id>
	<title>Blocking Process - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.foofun.cn//index.php?action=history&amp;feed=atom&amp;title=Blocking_Process"/>
	<link rel="alternate" type="text/html" href="http://wiki.foofun.cn//index.php?title=Blocking_Process&amp;action=history"/>
	<updated>2026-04-06T21:39:23Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.foofun.cn//index.php?title=Blocking_Process&amp;diff=302&amp;oldid=prev</id>
		<title>2022年1月24日 (一) 05:43 Zhang3</title>
		<link rel="alternate" type="text/html" href="http://wiki.foofun.cn//index.php?title=Blocking_Process&amp;diff=302&amp;oldid=prev"/>
		<updated>2022-01-24T05:43:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2022年1月24日 (一) 05:43的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l6&quot;&gt;第6行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第6行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== 休眠 Sleeping ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== 休眠 Sleeping ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;等待的一种特殊情况是休眠，这是指在给定的时间段 (例如20毫秒) 内将进程设置为非活动状态。 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;这通常是为了普通等待而单独处理的，主要是出于效率的考虑&lt;/del&gt;; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;由于时钟中断是很频繁的，并且跟踪单次中断是不可行的，因此通常的方法是使用相关的计数器系统来标记给定进程何时被唤醒。&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;等待的一种特殊情况是休眠，这是指在给定的时间段 (例如20毫秒) 内将进程设置为非活动状态。 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;主要是出于效率的考虑，休眠通常有一套区别于普通等待的单独处理策略&lt;/ins&gt;; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;由于时钟中断是很频繁的，并且跟踪每次时钟中断是不可行的，因此通常的方法是使用相关的计数器系统来标记给定进程何时被唤醒。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;用于跟踪休眠进程的常用数据结构是delta队列，这是一个有序的休眠进程列表，其中每个进程都有一个计数器，该计数器相对于之前列表中的最后一个进程偏移; 例如，如果进程A沉睡3个周期，进程B沉睡5个周期，进程C沉睡5个周期，进程D沉睡8个周期，那么列表将是&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;用于跟踪休眠进程的常用数据结构是delta队列，这是一个有序的休眠进程列表，其中每个进程都有一个计数器，该计数器相对于之前列表中的最后一个进程偏移; 例如，如果进程A沉睡3个周期，进程B沉睡5个周期，进程C沉睡5个周期，进程D沉睡8个周期，那么列表将是&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Zhang3</name></author>
	</entry>
	<entry>
		<id>http://wiki.foofun.cn//index.php?title=Blocking_Process&amp;diff=301&amp;oldid=prev</id>
		<title>Zhang3：创建页面，内容为“当一个进程process被设置为非活动状态时，它就被认为是阻塞blocking或等待waiting的，直到有发生特定事件。  == 进程阻塞 Blocking Process== 阻塞的进程通常正在等待诸如信号量被释放或消息到达其消息队列之类的事件。 在多任务系统中会期望这样的进程用系统调用通知调度器它要等待，以便它们可以从活动调度队列中删除，直到有需要的事件发生。 在等…”</title>
		<link rel="alternate" type="text/html" href="http://wiki.foofun.cn//index.php?title=Blocking_Process&amp;diff=301&amp;oldid=prev"/>
		<updated>2022-01-24T03:39:43Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“当一个进程process被设置为非活动状态时，它就被认为是阻塞blocking或等待waiting的，直到有发生特定事件。  == 进程阻塞 Blocking Process== 阻塞的进程通常正在等待诸如信号量被释放或消息到达其消息队列之类的事件。 在多任务系统中会期望这样的进程用系统调用通知调度器它要等待，以便它们可以从活动调度队列中删除，直到有需要的事件发生。 在等…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;当一个进程process被设置为非活动状态时，它就被认为是阻塞blocking或等待waiting的，直到有发生特定事件。&lt;br /&gt;
&lt;br /&gt;
== 进程阻塞 Blocking Process==&lt;br /&gt;
阻塞的进程通常正在等待诸如信号量被释放或消息到达其消息队列之类的事件。 在多任务系统中会期望这样的进程用系统调用通知调度器它要等待，以便它们可以从活动调度队列中删除，直到有需要的事件发生。 在等待时继续运行的进程 (即，在紧密循环中连续轮询事件) 被称为 [[Busy_loop| busy-waiting]]，这是不可取的，因为它浪费了可用于其他进程的时钟周期。&lt;br /&gt;
&lt;br /&gt;
== 休眠 Sleeping ==&lt;br /&gt;
&lt;br /&gt;
等待的一种特殊情况是休眠，这是指在给定的时间段 (例如20毫秒) 内将进程设置为非活动状态。 这通常是为了普通等待而单独处理的，主要是出于效率的考虑; 由于时钟中断是很频繁的，并且跟踪单次中断是不可行的，因此通常的方法是使用相关的计数器系统来标记给定进程何时被唤醒。&lt;br /&gt;
&lt;br /&gt;
用于跟踪休眠进程的常用数据结构是delta队列，这是一个有序的休眠进程列表，其中每个进程都有一个计数器，该计数器相对于之前列表中的最后一个进程偏移; 例如，如果进程A沉睡3个周期，进程B沉睡5个周期，进程C沉睡5个周期，进程D沉睡8个周期，那么列表将是&lt;br /&gt;
&lt;br /&gt;
 {A, 3} -&amp;gt; {B, 2} -&amp;gt; {C, 0} -&amp;gt; {D, 3}&lt;br /&gt;
&lt;br /&gt;
在每个时钟周期时，最顶层进程的计数器都会递减，如下所述:&lt;br /&gt;
&lt;br /&gt;
 {A, 2} -&amp;gt; {B, 2} -&amp;gt; {C, 0} -&amp;gt; {D, 3}&lt;br /&gt;
&lt;br /&gt;
如果此时添加了过程E，等待6个时钟周期，则它将在D之前插入，并且E和D都将适当地更新:&lt;br /&gt;
&lt;br /&gt;
 {A, 2} -&amp;gt; {B, 2} -&amp;gt; {C, 0} -&amp;gt; {E, 2} -&amp;gt; {D, 1}&lt;br /&gt;
&lt;br /&gt;
如果最上面的进程达到零，那么它 -- 以及紧随其后的任何同样为零的进程 -- 都将被放回活动调度队列中。 因此，在2个周期之后，A被设置为活动的; 2个周期之后，B和C都被设置为活动的; 依此类推。这种方法的优点是最大程度地减少了给定时钟周期中所需的更改数量。&lt;br /&gt;
&lt;br /&gt;
== 可中断和不中断 ==&lt;br /&gt;
&lt;br /&gt;
通常清晰的区分可中断等待/休眠和不中断等待/休眠是一个好主意。 根据你的系统，你可能希望大多数等待状态可中断，尽管你几乎肯定会需要一些不间断状态。 你可能需要考虑在不可中断等待之上构建可中断等待，而不是使用特殊标志。&lt;br /&gt;
&lt;br /&gt;
[[Category:Processes and Threads]]&lt;br /&gt;
[[Category:OS theory]]&lt;/div&gt;</summary>
		<author><name>Zhang3</name></author>
	</entry>
</feed>