本文介绍了什么是颠簸?为什么会发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在操作系统中,抖动与内存管理有关.为什么会发生颠簸?我们该如何预防呢?

In an operating system, thrashing is something related to memory management. Why does thrashing occur?How can we prevent it?

我查了维基百科(但我需要一些简单的理解).

I checked Wikipedia (but I need some simple understanding).

推荐答案

在实现虚拟内存空间的操作系统中,程序从可能比系统拥有的实际 RAM 量大得多的地址空间分配内存.操作系统负责决定哪些程序内存"在实际 RAM 中.它需要一个地方来存放外出"的东西.这就是所谓的交换空间",因为操作系统会根据需要交换东西.当这种交换活动发生时,it 是 CPU 时间的主要消耗者,那么你实际上是在颠簸.您可以通过运行更少的程序、编写更有效地使用内存的程序、向系统添加 RAM 甚至增加交换大小来防止它发生.

In operating systems that implement a virtual memory space the programs allocate memory from an address space that may be much larger than the actual amount of RAM the system possesses. The OS is responsible for deciding which programs "memory" is in actual RAM. It needs a place to keep things while they are "out". This is what is called "swap space", as the OS is swapping things in and out as needed. When this swapping activity is occurring such that it is the major consumer of the CPU time, then you are effectively thrashing. You prevent it by running fewer programs, writing programs that use memory more efficiently, adding RAM to the system, or maybe even by increasing the swap size.

当请求的内存访问(来自虚拟地址空间)没有映射到 RAM 中的某个内容时,就会发生页面错误.然后必须将一个页面从 RAM 发送到交换,以便可以将请求的新页面从交换带到 RAM.正如您可能想象的那样,用于读取 RAM 的 2 个磁盘 I/O 的性能往往很差.

A page fault occurs when the memory access requested (from the virtual address space) does not map to something that is in RAM. A page must then be sent from RAM to swap, so that the requested new page can be brought from swap to RAM. As you might imagine, 2 disk I/Os for a RAM read tends to be pretty poor performance.

这篇关于什么是颠簸?为什么会发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 05:19