现在的位置: 首页 > 综合 > 正文

并发进程的饥饿问题

2017年11月13日 ⁄ 综合 ⁄ 共 1315字 ⁄ 字号 评论关闭

本文转载至:http://blog.csdn.net/geekcome/article/details/7104508

什么是进程的饥饿和饿死?
在一个动态系统中,资源请求与释放是经常性发生的进程行为.对于每类系统资源,操作系统需要确定一个分配策略,当多个进程同时申请某类资源时,由分配策略确定资源分配给进程的次序。 资源分配策略可能是公平的(fair),能保证请求者在有限的时间内获得所需资源;资源分配策略也可能是不公平的(unfair),即不能保证等待时间上界的存在。 在后一种情况下,即使系统没有发生死锁,某些进程也可能会长时间等待.当等待时间给进程推进和响应带来明显影响时,称发生了进程饥饿(starvation),当饥饿到一定程度的进程所赋予的任务即使完成也不再具有实际意义时称该进程被饿死(starve
to death)。
考虑一台打印机分配的例子,当有多个进程需要打印文件时,系统按照短文件优先的策略排序,该策略具有平均等待时间短的优点,似乎非常合理,但当短文件打印任务源源不断时,长文件的打印任务将被无限期地推迟,导致饥饿以至饿死。
当等待时间给进程的推进和相应带来明显的影响时,就称发生了进程饥饿。当饥饿到一定程度的进程所赋予的任务即使完成也不再具有实际意义时,称该进程被饿死。

当一组进程到达时,CPU根据算法进行进程调度。有的进程因此而需要等待,而不能及时得到资源,这就叫饥饿。进程得到资源时,再完成已经不再具有意义,这就叫做饿死。

Starvation is simply when a process or service is not being serve, even when there is no deadlock on the system.

This is an example I just made up just for clarification purposes.

Imagine an algorithm that control computers access to a WAN or something like that. This algorithm could have a policy that says "Provide priority access to those computers that will use less bandwidth.", that will seem like a proper policy, but then what happens
when a single computer wants to access the network for an ftp upload that will send several GB somewhere. With this policy alone, that computer will starve since the algorithm will never select that computer, since there will be always other computers requesting
smaller bandwidth usage.

That is called starvation.

参考:http://stackoverflow.com/questions/1162587/what-is-starvation

抱歉!评论已关闭.