Поделиться через


Lazy-Writer Thread (Windows Embedded CE 6.0)

1/6/2010

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