One embodiment of the present invention provides a system which
facilitates selective prefetching based on resource availability. During
operation, the system executes instructions in a processor. While
executing the instructions, the system monitors the availability of one
or more system resources and dynamically adjusts an availability
indicator for each system resource based on the current availability of
the system resource. Upon encountering a prefetch instruction which
involves the system resource, the system checks the availability
indicator. If the availability indicator indicates that the system
resource is not sufficiently available, the system terminates the
execution of the prefetch instruction, whereby terminating execution
prevents prefetch instructions from overwhelming the system resource.