Docsity

MiniMIPS Pipelining and Cache Problems - Prof. Leona Mcmillan, Study notes of Computer Architecture and Organization

Partial preview of the text

Download MiniMIPS Pipelining and Cache Problems - Prof. Leona Mcmillan and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Comp 411

Final Study Session

Fall 2006

Final: 12/11 at 12:00pm in VN

Example Problem 1

Which of the following changes due to pipeliningminiMIPS require NO revisions to the Instruction SetArchitecture (ISA, i.e. the instruction’s behavior

or

performance)?A)^

Branch delay slots B)

Pipeline interlocks on lw instructions C)

Adding branch annulment D)

Adding early branch decision logic E)

Adding register by-passes

Example Problem 3

Which of the following is an advantage of the5-stage miniMIPS pipeline over the 4-stage miniMIPSpipeline?A)^

It has greater instruction execution latency B)

It has more register bypasses C)

It decreases the number of branch delay slots D)

It allows nearly 2-cycle for memory accesses E)

Two instruction following each load could insertNOPs if pipeline interlocking is implemented

Problem Setup

Suppose we designed a 16-locationdirect-mapped cache for miniMIPS whereeach cache line includes a valid bit(V), a tag field, and a 32-bit datafield. Lower-order address bits of theaddress select the cache line; theremaining bits are compared againstthe tag field.

Recall that miniMIPS

produces a 32-bit

byte

address, so the

bottom 2 bits are always “0” and arenot used by the cache.

Assume the

cache is used for both instruction anddata accesses and uses a

write-through

strategy on writes.

V^1514131211109876543210

Tag^

Data =? HIT^

CPU Data

CPU Addr

0x0108 1

0xDEADBEEF

Example Problem 5

Low-order address bits are used as cache indicesbecauseA)^

they are the first to arrive from the CPU.

B)

they ensure consecutive locations will be onthe same virtual page.

C)

we want nearby locations to occupy the

same

cache locations.

D)

we want nearby locations to occupy

different

cache locations.

E)

none of the above

Example Problem 6

If we check the valid bits in the cache afterrunning a large program for 100,000 cycles, whatpercentage of them would we expect to be on,i.e., marking the corresponding cache line asvalid?A)^

0% - none of them, “V” bits are not used in awrite-through cache

B)

Around 50%

C)

100% (all of them)

D)

Depends on the hit rate of the program

E)

Depends on the number of collisions

Example Problem 8

What is the 32-bit byteaddress of the memorydata currently cachedin entry 3?

Assume

that high-order bitsunspecified by hexconstants are zero. (A)^

0x (B)

0x (C)

0x (D)

0x420C (E)

Can’t

tell

from

the

information

provided

V^1514131211109876543210

Tag^

Data =? HIT^

CPU Data

CPU Addr

0x0108 1

0xDEADBEEF

Example Problem 9

Consider a virtual memory system that uses asingle-level page map to translate virtualaddresses into physical addresses.

Each of the

questions below asks you to consider whathappens when one of the design parameters of theoriginal system is changed. If the physicalmemory size (in bytes) is doubled, the number ofbits in each entry of the page table (A) Stays the same(B) Doubles(C) Is reduced by half(D) Increases by 1(E) Decreases by 1

Example Problem 11

11) If the virtual memory size (in bytes) is

doubled, the number of bits in each entry of thepage table (A) stays the same(B) Doubles(C) is reduced by half(D) increases by one(E) decreases by one

Example Problem 12

12) If the virtual memory size (in bytes) is

doubled, the number of entries in the page map (A) stays the same(B) Doubles(C) is reduced by half(D) increases by one(E) decreases by one

Example Problem 14

14) If the page size (in bytes) is doubled, the

number of entries in the page map (A) stays the same(B) Doubles(C) is reduced by half(D) increases by one(E) decreases by one

Problem Setup

The table on the rightshows the first 8 entriesin the page map.

Recall

that the valid bit is 1if the page is residentin physical memory and 0if the page is on disk orhasn’t been allocated.

1

1

7

4

0

6

5

0

5

5

1

4

2

1

3

3

0

2

9

1

1

7

0

0

Physical page

Valid bit

Virtual page

Example Problem 17

Consider the implementation of akernel handler for the ReadKey()service call shown on the right.ReadKey() will return the nextavailable keystroke from theuser’s keyboard, waiting until oneis available if necessary.ReadKey() {

if(BufferEmpty()) {

User.R27 = User.R27 – 4;scheduler(); } else

User.R2 =

ReadInputBuffer();} Recall that “User” is the kerneldata structure used to save thevalues of the user’s registersduring a trap or interrupthandler.

17) The user program that

executes the ReadKeysyscall reads theresult of the syscallcall from (A)

the top of the userstack (B)

the top of the kernelstack (C)

the $a0 slot of theUser structure (D)

the $a0 register (E)

the $v0 register

Example Problem 18

Consider the implementation of akernel handler for the ReadKey()service call shown on the right.ReadKey() will return the nextavailable keystroke from theuser’s keyboard, waiting until oneis available if necessary.ReadKey() {

if(BufferEmpty()) {

User.R27 = User.R27 – 4;scheduler(); } else

User.R2 =

ReadInputBuffer();} Recall that “User” is the kerneldata structure used to save thevalues of the user’s registersduring a trap or interrupthandler.

18)The

reason

for

the

call

to

scheduler()

in

this

routine

is (A)

it

avoids

a^

kernel-mode

loop

with

interrupts

disabled (B)

it

ensures

that

all

processes

get

an

equal

amount

of

CPU

time

(C)

it

gives

a^

chance

for

the

keyboard

interrupt

handler

to

run

(D)

it

gives

other

processes

a^ chance

to

run

while

waiting

for

the

next

keystroke

(E)

all

of

the

above