Dirty Bit

From COMP15212 Wiki
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