Dirty Bit: Difference between revisions

From COMP15212 Wiki
gravatar Yuron [userbureaucratinterface-adminsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
m (1 revision imported)
pc>Yuron
No edit summary
Line 5: Line 5:
(i.e. a write operation) has taken place.
(i.e. a write operation) has taken place.


Cached data begins as a <em>copy</em> of the data from some slower part of
Cached data begins as a <em>copy</em> of the data from some slower part of the system.  When reading this presents no problems.  If the data is written to it is often very inefficient to update the ‘real’ data – especially if there are likely to be more updates in the near future.  Instead, <em>just</em> the cached copy is changed and it is tagged as “dirty”.
the system.  When reading this presents no problems.  If the data is written to it is often very inefficient to update the ‘real’ data – especially if there are likely to be more updates in the near future.  Instead, <em>just</em> the cached copy is changed and it is tagged as “dirty”.


When – for whatever reason – the cached copy is about to be
When – for whatever reason – the cached copy is about to be abandoned the ‘dirty bit’ is checked.
abandoned the ‘dirty bit’ is checked.


*If the cache entry is clean it can simply be discarded.
*If the cache entry is clean it can simply be discarded.
*If the cache entry is dirty it must be copied down the hierarchy.<br /> This takes some additional time.
*If the cache entry is dirty it must be copied down the hierarchy.<br /> This takes some additional time.


This principle is used in several places in an operating system, most
This principle is used in several places in an operating system, most significantly in [[Virtual_Memory|virtual memory]] [[Page_Eviction|page eviction]].
significantly in [[Virtual_Memory|virtual memory]] [[Page_Eviction|page
eviction]].
<blockquote>
<blockquote>
Sometimes a [[Daemons|paging daemon]] is employed to
Sometimes a [[Daemons|paging daemon]] is employed to ‘clean’ pages periodically without evicting them (when nothing else more important is going on), which can save time later.
‘clean’ pages periodically without evicting them (when
nothing else more important is going on), which can save time later.
</blockquote>
</blockquote>
----
----
Line 26: Line 20:
=== Filing system example ===
=== Filing system example ===
In the [https://en.wikipedia.org/wiki/MS-DOS MS-DOS] [[File_Attributes | file attributes]] is a Boolean flag bit:
In the [https://en.wikipedia.org/wiki/MS-DOS MS-DOS] [[File_Attributes | file attributes]] is a Boolean flag bit:
‘archived’.  This is a software-available bit – not used
‘archived’.  This is a software-available bit – not used by the operating system – which was intended to flag that change had
by the operating system – which was intended to flag that change had
been made to the file.  Backup software could then check and clear this flag, only backing up altered files.
been made to the file.  Backup software could then check and clear
this flag, only backing up altered files.


Hopefully the similarity (in principle) is clear, as are the potential
Hopefully the similarity (in principle) is clear, as are the potential advantages.
advantages.
----
----
{{BookChapter|10.4.1|401-404}}
{{PageGraph}}
{{PageGraph}}
{{Category|Memory}}
{{Category|Memory}}

Revision as of 16:29, 31 July 2019

Depends on Memory Management Unit (MMU)Caching

Typically used in conjunction with caching in some form, a ‘dirty’ bit is used to indicate that a modification (i.e. a write operation) has taken place.

Cached data begins as a copy of the data from some slower part of the system. When reading this presents no problems. If the data is written to it is often very inefficient to update the ‘real’ data – especially if there are likely to be more updates in the near future. Instead, just the cached copy is changed and it is tagged as “dirty”.

When – for whatever reason – the cached copy is about to be abandoned the ‘dirty bit’ is checked.

  • If the cache entry is clean it can simply be discarded.
  • If the cache entry is dirty it must be copied down the hierarchy.
    This takes some additional time.

This principle is used in several places in an operating system, most significantly in virtual memory page eviction.

Sometimes a paging daemon is employed to ‘clean’ pages periodically without evicting them (when nothing else more important is going on), which can save time later.


Filing system example

In the MS-DOS file attributes is a Boolean flag bit: ‘archived’. This is a software-available bit – not used by the operating system – which was intended to flag that change had been made to the file. Backup software could then check and clear this flag, only backing up altered files.

Hopefully the similarity (in principle) is clear, as are the potential advantages.


Also refer to: Operating System Concepts, 10th Edition: Chapter 10.4.1, pages 401-404