装得下和装不下
运行下面这段程序,填写它打印出来的结果。
BLK = 4
LINES = 4
def cache(addrs):
tags = [-1] * LINES
hit = 0
miss = 0
for a in addrs:
b = a // BLK
line = b % LINES
if tags[line] == b:
hit = hit + 1
else:
miss = miss + 1
tags[line] = b
return hit, miss
a = cache(list(range(16)) * 2)
b = cache(list(range(32)) * 2)
print(str(a[1]) + "/" + str(b[1]) + "/" + str(b[1] // a[1]))
全部评论