os和操作系统_操作系统(OS)中的抛出

当页面错误和交换频繁发生时,操作系统需要花费大量时间进行交换,导致CPU利用率降低,这种状态称为Thrashing(抖动)。操作系统可能会采用全局或局部页面替换算法来应对,但效果有限。工作集模型和页面错误频率是处理Thrashing的两种技术,通过调整页面错误率的上下限来优化内存分配。
摘要由CSDN通过智能技术生成

os和操作系统

When a program need space larger than RAM or it need space when RAM is full, Operating System will try to allocate space from secondary memory and behaves like it has that much amount of memory by serving to that program. This concept is called virtual memory. To know about thrashing we first need to know what is page fault and swapping.

当程序需要的空间大于RAM或RAM满时需要空间时,操作系统将尝试从辅助内存分配空间,并且通过向该程序提供服务,其行为就好像它具有那么多的内存。 这个概念称为虚拟内存。 要了解颠簸,我们首先需要知道什么是页面错误和交换。

Page fault and swapping: We know every program divided into some pages. When a program need a page which is not in RAM that is called page fault. Whenever a page fault happens, operating system will try to fetch that page from secondary memory and try to swap it with one of the page in RAM. This is called swapping.

页面错误和交换:我们知道每个程序都分成一些页面。 当程序需要不在RAM中的页面时,称为页面错误。 每当发生页面错误时,操作系统都会尝试从辅助内存中获取该页面,并尝试将其与RAM中的页面之一交换。 这称为交换。

什么是操作系统中的Thrashing? (What is Thrashing  in OS?)

If this page fault and then swapping happening very frequently at higher rate, then operating system has to spend more time to swap these pages. This state is called thrashing. Because of this, CPU utilization is going to be reduced.

如果此页面故障然后以较高的速率频繁发生交换,则操作系统必须花费更多时间来交换这些页面。 这种状态称为抖动。 因此,CPU使用率将降低。

Thrashing in Operating System (OS)

脱粒的效果 (Effect of Thrashing)

Whenever thrashing starts, operating system tries to apply either Global page replacement Algorithm or Local page replacement algorithm.

无论何时开始崩溃,操作系统都会尝试应用全局页面替换算法或本地页面替换算法。

Global Page Replacement

全局页面替换

Since global page replacement can access to bring any page, it tries to bring more pages whenever thrashing found. But what actually will happen is, due to this, no process gets enough frames and by result thrashing will be increase more and more. So global page replacement algorithm is not suitable when thrashing happens.

由于全局页面替换可以访问任何页面,因此只要发现不正常,它就会尝试带来更多页面。 但是,实际上将要发生的是,因此,没有进程获得足够的帧,结果抖动的影响将越来越大。 因此,当发生颠簸时,全局页面替换算法不适合。

Local Page Replacement

本地 页面替换

Unlike global page replacement algorithm, local page replacement will select pages which only belongs to that process. So there is a chance to reduce the thrashing. But it is proven that there are many disadvantages if we use local page replacement. So local page replacement is just alternative than global page replacement in thrashing scenario.

与全局页面替换算法不同,本地页面替换将选择仅属于该进程的页面。 因此,有机会减少抖动。 但是事实证明,如果我们使用本地页面替换,则存在许多缺点。 因此,在发生颠簸的情况下,本地页面替换只是全局页面替换的替代方法。

处理脱粒的技术 (Techniques to Handle Thrashing)

We already seen Local replacement is better than Global replacement to avoid thrashing. But it also has disadvantages and not suggestable. Some more techniques are

我们已经看到,本地替换比全局替换要好,以避免崩溃。 但这也有缺点,并不明显。 还有更多技术

Working Set Model

工作集模型

This model is based on locality. What locality is saying, the page used recently can be used again and also the pages which are nearby this page will also be used. Working set means set of pages in the most recent D time. The page which completed its D amount of time in working set automatically dropped from it. So accuracy of working set depends on D we have chosen. This working set model avoid thrashing while keeping the degree of multiprogramming as high as possible.

该模型基于位置。 本地人说的是,可以再次使用最近使用过的页面,并且也可以使用该页面附近的页面。 工作集是指最近D时间的一组页面。 在工作集中完成其D个时间量的页面会自动从中删除。 因此,工作集的准确性取决于我们选择的D。 该工作集模型避免了抖动,同时保持了尽可能高的多重编程程度。

Page Fault Frequency

页面故障频率

Page Fault Frequency

It is some direct approach than working set model. When thrashing occurring we know that it has few number of frames. And if it is not thrashing that means it has too many frames. Based on this property we assign an upper and lower bound for the desired page fault rate. According to page fault rate we allocate or remove pages. If the page fault rate become less than the lower limit, frames can be removed from the process. Similarly, if the page fault rate become more than the upper limit, more number of frames can be allocated to the process. And if no frames available due to high page fault rate, we will just suspend the processes and will restart them again when frames available.

这是比工作集模型更直接的方法。 发生抖动时,我们知道帧数很少。 如果没有抖动,则表示帧太多。 基于此属性,我们为所需的页面错误率指定一个上限和下限。 根据页面错误率,我们分配或删除页面。 如果页面错误率小于下限,则可以从过程中删除帧。 同样,如果页面错误率大于上限,则可以为该进程分配更多的帧数。 如果由于高页面错误率而导致没有可用的帧,我们将暂停进程,并在可用帧时重新启动它们。

Source: https://www.geeksforgeeks.org/operating-system-techniques-handle-thrashing/

资料来源: https : //www.geeksforgeeks.org/operating-system-techniques-handle-thrashing/

翻译自: https://www.thecrazyprogrammer.com/2019/02/thrashing-in-operating-system-os.html

os和操作系统

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值