
283
Chapter 5 Operating System Issues
When register stack filling occurs, a LOADM instruction is used to restore local
registers which were previously spilled. The data loaded during the filling will be
allocated in the cache and possibly displace other cached data. However, the filled
data is intended for the register file only, and will never be accessed by load and store
instructions. This somewhat reduces the effectiveness of the cache; but, since
register stack filling is a very infrequent occurrence it is unlikely to have any serious
impact on performance.
If filling always occurred in Supervisor mode, it would be very easy to add code
to the
fill_handler
(see section 4.4.5) which disabled the data cache on entry and
reenabled the cache after the LOADM instruction. Valid data is retained in the cache
while it is disabled. The cache is disabled and enabled in Supervisor mode by
respectively setting and clearing the DD bit in the CFG configuration register. This
would prevent any cached data being replaced by the fill operation. However, filling
is normally accomplished by trampolining from a Supervisor mode trap handler,
FillTrap
(see section 4.4.3), to the User mode
fill_handler
. This introduces a
difficulty. It would be simple to disable the cache in the
FillTrap
code, but after
returning to User mode, access to the CFG register is not directly permitted. It would
be possible to take a trap at the end of
fill_handler
to reenter Supervisor mode,
enable the data cache and then IRET back, but it seems unlikely that the additional
overhead (although small) would produce a noticeable performance gain. Another
difficulty with temporarily disabling the cache is that an interrupt may occur. The
interrupt handler or operating system support code would then have the burden of
reenabling the cache. However, it may be worthwhile for operating system code to
disable the data cache while reloading the local register file during a task context
restore.
5.14.2 Am29040 2–bus Microprocessor
A block diagram of the Am29040 cache architecture is shown on Figure 5-9.
The precise silicon implementation may differ from the diagram but the data flow
paths can be seen.
The default policy of the cache is “copy–back” rather than “write–through”.
Stores do not always cause writes to off–chip memory, as is the case with a
write–through policy. Consider when a currently valid cache block is to be
reassigned to a new memory location. The write–through policy enables the block to
be simply reallocated without having to copy its contents to memory. The copy–back
policy eliminates the need to write all stores to memory, but requires that reallocated
blocks be copied–back to memory before they can be used for higher priority data.
To improve the performance of the copy–back policy, the processor has a four
word copy–back buffer which is loaded in a single cycle. This makes the selected
block immediately available for reload. The copy–back buffer data is transferred to
memory when the system bus becomes available –– certainly after reload is