Dirty Bit

What is Dirty Bit?

A dirty bit in the memory is a single bit which is switched on when a page is updated or modified by the hardware of the computer and replaced in the memory.

Technically, when a bit is not written back onto the storage even after it is modified by the CPU, it is referred to as a dirty bit.

In simple words, a dirty bit is a flag which tells whether or not there is any need to update an attribute.

Understanding Dirty Bit

What is Dirty Bit

A dirty bit is a colloquial computer jargon used to refer to a particular bit residing in the memory of the computer.

This specific bit can be used by the regular computing systems to indicate specific things, namely:

In its simplest forms, a dirty bit is a concept that refers to a place marker. This is temporary because it will be erased eventually by the algorithms of the operating system and other tools.

Strange as it may sound, a dirty bit is also referred to as a modified bit. For specific types of modifications, a dirty bit is added to the memory by the computer system.

In technical terms, a dirty bit represents a specific and temporary spot on the memory of the computer that indicates some specific function or condition. A dirty bit can reside in any of the two following places, such as:

Such a bit may occur when a bit in the virtual memory page or in the cache memory is changed by the CPU but is not updated yet in the storage.

The primary use of the dirty bit is:

It also helps in page replacement, where every page may have a modified bit linked to it in the hardware. The hardware sets this bit for the page when a byte or a word in it needs to be modified.

The modified bit or dirty bit is examined in that case when a page is designated for replacement. And, in such situations, there can be two specific possibilities, such as:

In Which Protocol Dirty Bit is Used?

The dirty bit theory is typically used in the write-back policy in the cache, a process in which the updates are written only on the cache.

Therefore, a dirty bit normally indicates that a page has been modified after it is loaded into the cache memory.

Read Also:  RDIMM (Registered Dual Inline Memory Module) Explained

In normal conditions, a dirty bit is set when a line is modified and it is selected for replacement. This is very important because without the dirty bit being set, the line cannot be written into the main memory.

Ideally, according to the working principle of cache memory, during the write-back process, the cache copy is written first in order to update the memory.

This is usually done by the dirty bit, because the data is written back to the cache only when the dirty bit is set to 1. This means that while writing back cache, two things are essentially required, such as:

If it is written only when the memory is different from the write data, the number of write-backs can be reduced as well.

Why Use Dirty Bit in Cache Design?

Dirty bit is used in a cache design because it helps in reducing the write operations into the memory.

Usually, every block in the cache memory requires a bit to indicate two specific statuses of the data present in the cache, such as:

If the data is clean then there is no need to write it into the memory, which eventually reduces the write operations on the whole.

What is the Dirty Bit for a Page Table?

Dirty bit for a page in a page table refers to the phenomenon which helps in avoiding performing write operations unnecessarily on a paging device.

Usually, a dirty bit is related to a block of computer memory. It is used to indicate whether or not a corresponding block in the memory is modified. It is set when the Central Processing Unit (CPU) writes to the memory.

As said earlier, when a memory block needs to be replaced, the dirty bit corresponding to it in the page table is verified.

It helps to determine whether or not there is any need to write back the specific block to a secondary memory before it is replaced or can it be replaced simply.

Typically, the dirty bit is used in page replacement algorithms of the operating system by the CPU.

Read Also:  What is ECC (Error Correction Code) Memory? (Explained)

When the dirty bit is switched on or set to 1, a modification is made on the page. When it is switched off, no replacement is made because there is no need to make any updates to the page.

Ideally, a page of information in the memory initiates from the mass storage.

The Page Fault handler of the operating system copies it into the memory and a program needs access to a specific or a number of different locations in that page. In these situations, this is what actually happens:

When the dirty bit is set to 1, it signifies that the copy of the page in the memory is different from the original page on the mass storage.

When these are set, the programmer takes the responsibility to erase the bit. Remember, it is not the responsibility of the processor of the computer to remove these bits.

What Does Dirty Bit Do?

Dirty bits typically assist the page replacement algorithms of the operating system and the CPU cache in their proper functioning.

It also marks the data segments that are yet to be processed, which, in turn, helps in incremental computing.


Therefore, in the end, it can be said that a dirty bit is a computer jargon that indicates a bit in the memory.

This specific bit tells the operating system of the computer that it is needed to write new data to the disk.

Once this new data is written onto the memory, the dirty bit is normally removed or deactivated.