Share via


Lazy-Writer Thread

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

Each cache has its own lazy-writer thread that searches for and commits dirty sectors. By default, the priority of this thread is set to idle. However, you can override this priority for a profile, using the following registry setting:

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<Profile Name>\FATFS]
   "LazyWriterThreadPrio256"=dword:xx

The lazy-writer thread uses the following algorithm:

if (event set indicating that there are dirty sectors to commit) {
   while (TRUE){
      Enter main critical section protecting the cache from main threads;
      if (no more dirty sectors)
      {
          Leave main critical section;
          break;
      }
      Find first dirty run of sectors to commit;
      Commit those dirty sectors;
      Leave main critical section;
   }
}
Reset event indicating there are no dirty sectors to commit.

A main thread cannot interrupt the lazy-writer thread while it is committing dirty sectors. However, since the lazy-writer thread always leaves the main critical section, a main thread has priority in fulfilling its requests. The dirty sector check occurs while the lazy-writer thread holds the critical section to prevent race conditions. It then checks the dirty sector count and resets the event.

See Also

Concepts

Disk Cache Management