A dirty bit or modified bit is a
bit
The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
that is associated with a block of computer memory and indicates whether the corresponding block of memory has been modified. The dirty bit is set when the
processor
Processor may refer to:
Computing Hardware
* Processor (computing)
**Central processing unit (CPU), the hardware within a computer that executes a program
*** Microprocessor, a central processing unit contained on a single integrated circuit (I ...
writes to (modifies) this memory. The bit indicates that its associated block of memory has been modified and has not been saved to
storage yet. When a block of memory is to be replaced, its corresponding dirty bit is checked to see if the block needs to be written back to secondary memory before being replaced or if it can simply be removed. Dirty bits are used by the
CPU cache
A CPU cache is a hardware cache used by the central processing unit (CPU) of a computer to reduce the average cost (time or energy) to access data from the main memory. A cache is a smaller, faster memory, located closer to a processor core, which ...
and in the
page replacement algorithm
In a computer operating system that uses paging for virtual memory management, page replacement algorithms decide which memory pages to page out, sometimes called swap out, or write to disk, when a page of memory needs to be allocated. Page repl ...
s of an
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
.
Dirty bits can also be used in
Incremental computing
Incremental computing, also known as incremental computation, is a software feature which, whenever a piece of data changes, attempts to save time by only recomputing those outputs which depend on the changed data.
When incremental computing is su ...
by marking segments of data that need to be processed or have yet to be processed. This
technique
Technique or techniques may refer to:
Music
* The Techniques, a Jamaican rocksteady vocal group of the 1960s
*Technique (band), a British female synth pop band in the 1990s
* ''Technique'' (album), by New Order, 1989
* ''Techniques'' (album), by M ...
can be used with delayed computing to avoid unnecessary processing of objects or states that have not changed. When the model is updated (usually by multiple sources), only the segments that need to be reprocessed will be marked dirty. Afterwards, an algorithm will scan the model for dirty segments and process them, marking them as clean. This ensures the unchanged segments are not recalculated and saves processor time.
Page replacement
When speaking about page replacement, each
page
Page most commonly refers to:
* Page (paper), one side of a leaf of paper, as in a book
Page, PAGE, pages, or paging may also refer to:
Roles
* Page (assistance occupation), a professional occupation
* Page (servant), traditionally a young m ...
may have a modify bit associated with it in the hardware. The dirty bit for a page is set by the hardware whenever any word or
byte
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit ...
in the page is written into, indicating that the page has been modified. When a page is selected for replacement, the modify bit is examined. If the bit is set, the page has been modified since it was read in from the
disk
Disk or disc may refer to:
* Disk (mathematics), a geometric shape
* Disk storage
Music
* Disc (band), an American experimental music band
* ''Disk'' (album), a 1995 EP by Moby
Other uses
* Disk (functional analysis), a subset of a vector sp ...
. In this case, ''the page must be written to the disk''. If the dirty bit is not set, however, the page has not been modified since it was read into
memory
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembered, ...
. Therefore, if the copy of the page on the disk has not been overwritten (by some other page, for example), then there is no need to write the memory page to the disk: it is already there.
References
{{Reflist
Central processing unit
Operating system technology