⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcachecbio.html

📁 Vxworks API操作系统和驱动程序设计API。压缩的HTML文件
💻 HTML
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/dcacheCbio.html - generated by refgen from dcacheCbio.c --> <title> dcacheCbio </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference :  OS Libraries</i></a></p></blockquote><h1>dcacheCbio</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>dcacheCbio</strong> - Disk Cache Driver </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./dcacheCbio.html#dcacheDevCreate">dcacheDevCreate</a>(&nbsp;)</b>  -  Create a disk cache<br><b><a href="./dcacheCbio.html#dcacheDevDisable">dcacheDevDisable</a>(&nbsp;)</b>  -  Disable the disk cache for this device<br><b><a href="./dcacheCbio.html#dcacheDevEnable">dcacheDevEnable</a>(&nbsp;)</b>  -  Reenable the disk cache<br><b><a href="./dcacheCbio.html#dcacheDevTune">dcacheDevTune</a>(&nbsp;)</b>  -  modify tunable disk cache parameters<br><b><a href="./dcacheCbio.html#dcacheDevMemResize">dcacheDevMemResize</a>(&nbsp;)</b>  -  set a new size to a disk cache device<br><b><a href="./dcacheCbio.html#dcacheShow">dcacheShow</a>(&nbsp;)</b>  -  print information about disk cache<br><b><a href="./dcacheCbio.html#dcacheHashTest">dcacheHashTest</a>(&nbsp;)</b>  -  test hash table integrity<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p><p>This module implements a disk cache mechanism via the CBIO API.This is intended for use by the VxWorks DOS file system, to storefrequently used disk blocks in memory.  The disk cache is unaware of the particular file system format on the disk, and handles thedisk as a collection of blocks of a fixed size, typically the sectorsize of 512 bytes.  <p>The disk cache may be used with SCSI, IDE, ATA, Floppy or any othertype of disk controllers.  The underlying device driver may be eithercomply with the CBIO API or with the older block device API.  <p>This library interfaces to device drivers implementing the block device API via the basic CBIO <b>BLK_DEV</b> wrapper provided by <b><a href="./cbioLib.html#top">cbioLib</a></b>.<p>Because the disk cache complies with the CBIO programming interface onboth its upper and lower layers, it is both an optional and a stackablemodule.   It can be used or omitted depending on resources available and performance required.<p>The disk cache module implements the CBIO API, which is used by the filesystem module to access the disk blocks, or to access bytes within a particular disk block.  This allows the file system to use the disk cacheto store file data as well as Directory and File Allocation Table blocks, on a Most Recently Used basis, thus keeping a controllable subset of thesedisk structures in memory.  This results in minimized memory requirements for the file system, while avoiding any significant performance degradation.<p>The size of the disk cache, and thus the memory consumption of the disksubsystem, is configured at the time of initialization (see <b><a href="./dcacheCbio.html#dcacheDevCreate">dcacheDevCreate</a>(&nbsp;)</b>), allowing the user to trade-off memory consumptionversus performance.  Additional performance tuning capabilities areavailable through <b><a href="./dcacheCbio.html#dcacheDevTune">dcacheDevTune</a>(&nbsp;)</b>.<p>Briefly, here are the main techniques deployed by the disk cache:<ul><li></li>Least Recently Used block re-use policy<li></li>Read-ahead<li></li>Write-behind with sorting and grouping<li></li>Hidden writes<li></li>Disk cache bypass for large requests<li></li>Background disk updating (flushing changes to disk) with an adjustableupdate period (ioctl flushes occur without delay.)</ul><p>Some of these techniques are discussed in more detail below; others are described in varrious professional and academic publications.<p></blockquote><h4>DISK CACHE ALGORITHM</h4><blockquote><p>The disk cache is composed internally of a number cache blocks, ofthe same size as the disk physical block (sector). These cache blocksare maintained in a list in "Most Recently Used" order, that is, blockswhich are used are moved to the top of this list. When a block needs tobe relinquished, and made available to contain a new disk block, theLeast Recently Used block will be used for this purpose.<p>In addition to the regular cache blocks, some of the memory allocatedfor cache is set aside for a "big buffer", which may range from 1/4 ofthe overall cache size up to 64KB.  This buffer is used for:<p><ul><li></li>Combining cache blocks with adjacent disk block numbers, in order towrite them to disk in groups, and save on latency and overhead <li></li>Reading ahead a group of blocks, and then converting them to normalcache blocks.</ul><p>Because there is significant overhead involved in accessing the diskdrive, read-ahead improves performance significantly by reading groupsof blocks at once.<p></blockquote><h4>TUNABLE PARAMETERS</h4><blockquote><p>There are certain operational parameters that control the disk cacheoperation which are tunable. A number of<i>preset </i>parameter sets is provided, dependent on the size of the cache. Theseshould suffice for most purposes, but under certain types of workload,it may be desirable to tune these parameters to better suite theparticular workload patterns.<p>See <b><a href="./dcacheCbio.html#dcacheDevTune">dcacheDevTune</a>(&nbsp;)</b> for description of the tunable parameters. It isrecommended to call <b><a href="./dcacheCbio.html#dcacheShow">dcacheShow</a>(&nbsp;)</b> after calling <b>dcacheTune(&nbsp;)</b> in order to verify that the parameters where set as requested, and to inspect the cache statistics which may change dramatically. Note that the hit ratio is a principal indicator of cache efficiency, and should be inspectedduring such tuning.<p></blockquote><h4>BACKGROUND UPDATING</h4><blockquote><p>A dedicated task will be created to take care of updating the disk withblocks that have been modified in cache. The time period between updatesis controlled with the tunable parameter syncInterval. Its priorityshould be set above the priority of any CPU-bound tasks so as to assureit can wake up frequently enough to keep the disk synchronized with thecache.   There is only one such task for all cache devices configured.  The task name is tDcacheUpd<p>The updating task also has the responsibility to invalidate disk cacheblocks for removable devices which have not been used for 2 seconds or more.<p>There are a few global variables which control the parameters of thistask, namely:<p><dl><dt><i>dcacheUpdTaskPriority</i><dd>controls the default priority of the update task, and is set by default to 250.<p><dt><i>dcacheUpdTaskStack</i><dd>is used to set the update task stack size.<p><dt><i>dcacheUpdTaskOptions</i><dd>controls the task options for the update task.</dl>All the above global parameters must be set prior to calling<b><a href="./dcacheCbio.html#dcacheDevCreate">dcacheDevCreate</a>(&nbsp;)</b> for the first time, with the exception ofdcacheUpdTaskPriority, which may be modified in run-time, and takeseffect almost immediately. It should be noted that this priority is notentirely fixed, at times when critical disk operations are performed,and FIOFLUSH ioctl is called, the caller task will temporarily<i>loan </i>its priority to the update task, to insure the completion of the flushingoperation.<p></blockquote><h4>REMOVABLE DEVICES</h4><blockquote><p>For removable devices, disk cache provides these additional features:<p><dl><dt>disk updating<dd>is performed such that modified blocks will be written to disk withinone second, so as to minimize the risk of losing data in case of afailure or disk removal.<dt>error handling<dd>includes a test for disk removal, so that if a disk is removed from thedrive while an I/O operation is in progress, the disk removal event willbe set immediately.<dt>disk signature<dd>which is a checksum of the disk's boot block, is maintained by the cachecontrol structure, and it will be verified against the disk if it wasidle for 2 seconds or more. Hence if during that idle time a disk wasreplaced, the change will be detected on the next disk access, and thecondition will be flagged to the file system.<p><dt>NOTE<dd>It is very important that removable disks should all have a uniquevolume label, or volume serial number, which are stored in the disk'sboot sector during formatting. Changing disks which have an identicalboot sector may result in failure to detect the change, resulting inunpredictable behavior, possible file system corruption.</dl><p></blockquote><h4>CACHE IMPLEMENTATION</h4><blockquote><p><p>Most Recently Used (MRU) disk blocks are stored in a collection of memorybuffers called the disk cache.  The purpose of the disk cache is to reduce the number of disk accesses and to accelerate disk read and write operations, by means of the following techniques:<p><ul><li></li>Most Recently Used blocks are stored in RAM, which results in the mostfrequently accessed data being retrieved from memory rather than from disk.<li></li>Reading data from disk is performed in large units, relying on the read-aheadfeature, one of the disk cache

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -