代写CSC 252 Computer Organization Final Exam 2022代做回归

Computer Science Department

Final Exam

CSC 252

Computer Organization

4 May 2022

Problem 0: Warm-up (3 Points)

Do you think 252 could be taught in high school?

Problem 1: Miscellaneous (12 points)

Part a) (3 points) Write down the sum of 328  and 0x32 in base 2.

Part b) (3 points) Generally, the access time of a direct-mapped cache is  ___ than that of a fully associative cache that is the same total size. Answer with <, >, =, <=, or >=.

Part c) (3 points) (True or False) Virtual memory has no size limitation.

Part d) (3 points) Consider the following C struct Person:

struct Person{

long id;

float age;

float weight;

float height;

char name [20];

char sex [7];

struct Person * nextPerson;

};

What’s the size of the struct Person?

Problem 2: ISA (18 points)

A stack-based ISA is designed. The ISA uses a hardware stack, and instructions in this ISA manipulate this stack. Each entry on the stack is one byte long, and the memory is byte-addressable. All instructions are 8-bit long, and are classified into two categories.

R Category

Binary encoding:

OpCode<7-5 bits="">

00000<4-0 bits="">

Instruction list:

Instruction

OpCode

Role

pop

001

Remove the item at the top of the stack.

halt

001

Halt the processor.

I Category

Binary encoding:

OpCode<7-5 bits="">

Immediate value in 2’s component<4-0 bits="">

Instruction list:

Instruction

OpCode

Role

push i

000

Push sign-extended immediate value on the stack.

load

101

Let the top entry of the stack be A.

Compute Address = A + sign-extended immediate value; Pop A from the stack;

Use Address to load a byte from the main memory and push the byte on the stack.

store

100

Let the top entry of the stack be A, and the second entry of the stack be B.

Compute Address = A + sign-extended immediate value; Pop A from the stack;

Store B at the memory location Address;

Pop B from the stack.

loadd

110

Address = sign-extended immediate value. Load a byte from the memory using Address and push the byte on the stack.

Part a) (12 points) Encode the following instructions in binary. (4 points) store -8

(4 points) push i 7

(4 points) halt

Part b) (6 points) You want to implement a function that pops the top value from the stack and then pushes it back on the stack twice. Memory location at address 0 is reserved for this instruction to use temporarily. Write an assembly program using the existing instructions to implement this function.

Problem 3: Floating-Point Arithmetic (25 points)

Suppose that the IEEE decided to add a new n-bit floating-point standard, with its main characteristics consistent with the other IEEE standards. This n-bit standard can precisely represent the value 6 16/3, but cannot precisely represent 11 16/7 . The smallest positive

normalized value that can be represented in this standard is 2−30 .

Part a) (3 points) Convert 6 16/3 to Binary Normalized Form.

Part b) (3 points) How many of the n bits are fraction bits?

Part c) (3 points) What’s the bias of this standard?

Part d) (3 points) How many of the n bits are exponent bits?

Part e) (3 points) What is n?

Part f) (10 points) Suppose that using this new IEEE standard you perform. two separate calculations, assume nearest-even rounding is used:

1. (256 + 2 4/1) - 256

2. (256 - 256) + 2 4/1

What would be the result of these calculations? Do they both result in equivalent mathematically precise answers? Show your math to earn partial credit.

Problem 4: Cache (20 points)

For all the questions in this problem, assume that we are using a 12-bit machine with a byte-addressable memory and a direct-mapped cache. The cache can hold up to 16 cache lines.

Part a) (3 points) How many bits do you need for the set index?

Part b) (17 points) The following sequence of 9 memory accesses generates the hits/misses shown. Some miss/hit entries are intentionally left blank. The cache is initially empty. Note that the addresses are written in binary with spaces added between each 4 bits for readability. These  are not necessarily the tag/index/offset boundaries.

#

Address

Hit/Miss

1

1101 1111 0000

Miss

2

0000 1101 1111

Miss

3

1101 0111 0101

Miss

4

0000 1101 1100

Hit

5

1101 1111 0011

Miss

6

1111 0111 0010


7

1101 1111 0000


8

0000 1101 1101


9

1111 0111 0100


(3 points) What is the number of tag bits?

(3 points) What is the number of offset bits?

(3 points) What is the size of each cache line (ignore the valid bit, dirty bit, and tag bits etc.)? Show the formula you used to calculate this, and the value you get from it.

(8 points) Fill the miss/hit for each of the blank entries.

Problem 5: Assembly Programming (26 points)

Conventions:

1.   For this section, the assembly shown uses the AT&T/GAS syntax opcode src, dst

for instructions with two arguments where src is the source argument and dst is the destination argument. For example, this means that mov a, b moves the value a into b.

2.  All C code is compiled on a 64-bit machine, where arrays grow toward higher addresses.

3.   For functions that take an argument, the argument is stored in %rdi at the time the

function is called. The return value of this function is stored in %rax at the time the function returns.

Consider the assembly of a C function void foobar (int *x) which takes a single int pointer parameter x.

0000000000001159 :

1159:     mov  (%rdi),%eax

115b:      inc  %eax

115d:     mov  %eax, (%rdi)

115f:      lea  0x2ecf,%rdi

1166:      cmp  $0x1,%eax

1169:     je   1177

116b:      cmp  $0x2,%eax

116e:     jne  117c

1170:      lea  0x2eb4,%rdi

1177:     call 1030

117c:      ret

The addresses 0x2ecf and 0x2eb4 contain the beginning of character strings “foo” and “bar” respectively. puts () is a standard C function that prints a character string given the string start address as a parameter.

Part a) (9 points)

(3 points) When the initial value of *x is 0, what is printed by the program?

(3 points) When the initial value of *x is 1, what is printed by the program?

(3 points) The call on line 1177 is replaced with a jmp. Would this program still run correctly? Explain your answer.

Part b) (17 points)

Assuming that there are two threads, each of which executes the same foobar () function with the same exact parameter x. *x is initially set to 0. For the sake of this problem, assume that the instructions inside the puts () function are always executed as an atomic unit (they are either executed together without interruption or not executed at all).

(4 points) What are all the possible values of *x after both threads finish execution of foobar ()?

(4 points) What are all the possible strings printed by this multi-threaded program?

(3 points) Suppose the first three instructions (1159 to 115d) could be replaced with a single atomic instruction called csc252. Would this guarantee that the program always ends with x containing the value 2? Show you work to earn partial credit.

(3 points) Would this guarantee that the program always prints the same string no matter how many times you run it? Show you work to earn partial credit.

(3 points) Assuming that the two threads execute on two different processors, each with a separate cache. What is something that the processor designers have to pay attention to in order to correctly implement the csc252 instruction?

Problem 6: Virtual Memory (26 points)

Assume a virtual memory system that has the following characteristics:

1.   The virtual address space is 32 KB and is byte addressable

2.   Physical memory size is 8 KB and is byte addressable

3.   Page size is 128 Bytes

4.   One level page table, where each page table entry contains a valid bit, a dirty bit, and the physical page number

5.   PTBR is 0x3ADC

6.   There is a data TLB that stores only the last page table entry

The format of a PTE is as shown below. MSB is the valid bit followed by the dirty bit. Last few bits are the physical page number (PPN).

Part a) (3 points) What are the number of physical and virtual pages?

Part b) (3 points) What is the total size of the page table?

Consider the following C program:

void fibbo (int a [64]) {

a [0] = 0

a [1] = 1

for (int i=2; i < 64; i++) {

a [i] = a [i-2] + a [i-1];

}

}

Suppose that the virtual address of the array ‘a’ is 0x0400. Assume the data TLB is empty when the code starts execution. The table below shows a part of the main memory before the code executes.

Address

Data

3ADC

B8

3ADD

3A

3ADE

CD

3ADF

78

3AE4

F9

3CDC

B6

3DDC

4F

3EDC

F0

Part c) (4 points) How many pages does array ‘a’ occupy?

Part d) (4 points) To read a [1], what virtual page number(s) is(are) accessed?

Part e) (8 points) What physical memory addresses are accessed when reading a [1]?

Part f) (4 points) How many data TLB misses will occur in the execution of the program? Assume the access order of the line “a [i] = a [i-2] + a [i-1];” is a [i-2], a [i-1],  a [i] with no other accesses in between.




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图