April 1998
Intermediate to advanced
624 pages
16h 11m
English
The kernel spends a large proportion of its time copying or zeroing blocks of data. These blocks may be internal buffers or data structures, but a common operation involves zeroing or copying a page of memory, which is 4 Kbytes or 8 Kbytes. The data is not often used again immediately, so it does not need to be cached. In fact, the data being copied or zeroed will normally remove useful data from the cache. The standard C library routines for this operation are called bcopy and memcpy; they handle arbitrary alignments and lengths of copies.
The most efficient way to copy a page on a system with a write-back cache is to read a cache line, then write it as a block, using two bus transactions. The sequence ...