代写CSC 252 Computer Organization Final Exam 2023代做Java程序

Computer Science Department

Final Exam

CSC 252

Computer Organization

1 May 2023

Problem 0: Warm-up (3 Points)

Are you grateful that 252 is not an elective?

Problem 1: Miscellaneous (17 points) (3 points) Write 0xFACE in binary.

(3 points) The fork () system call spawns a new thread in the parent process; True or False?

(3 points) malloc () allocates physical memory in DRAM; True or False?

(4 points) List two advantages of using virtual memory over physical memory.

(4 points) What can happen if multiple threads access resources held by multiple locks?

Problem 2: Floating-Point Arithmetics (20 points)

Part a)   (6 points) Basic Arithmetics

(3 points) Write the result of 6+(16/64) in the normalized binary form.

(3 points) Compute 1.1 × 2-2  × 1.001 × 24. Write the result in the normalized binary form. Show your work to earn partial credit.

Part b) (6 points) True or False questions.

(3 points) The IEEE 754 single precision floating point representation can be used to precisely represent all rational numbers between 0 and 1.

(3 points) The IEEE 754 double precision floating point representation can be used to precisely represent all real numbers between 0 and 1.

Part c) (4 points) Consider the following C code.

int x = 0x8f7;

int* pi = &x;

float* pf = (float*) pi;

Assume data is stored in little-endian format and int variables are 4 bytes aligned. Now we dereference pf and print its value, what will we get?

(a) It will give a N an

(b) It will give a floating point number equal to the integer 0x8f7

(c) It will give a subnormal number

(d) There is a syntax error because we cannot cast an int pointer to a float pointer

Part d) (4 points) In most programming languages when we want to calculate 0.3 × 3.0, we won’t get 9.0; instead we might get something like 0.89999999999999991. What is the most   likely cause of this?

Problem 3: Assembly Programming (24 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 and cmp a, b thenjge c would compare b to a then jump to c if b ≥ a.

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

3.   We use the x86 calling convention. That is, for functions that take two arguments, the

first argument is stored in %edi (%rdi) and the second is stored in %esi (%rsi) at the    time the function is called; the return value of a function is stored in %eax (%rax) at the time the function returns.

4.   We use the Little Endian byte order when storing multi-byte variables in memory.

The declaration of function y () is given below; its function body is intentionally incomplete.

The first parameter of the function, arr, is the pointer to an array of 5 elements. y () will iterate over each element in the arr array exactly once and update each element if and only if a condition is met.

Consider the following assembly code. Before executing the code, %rdi contains a pointer to an array [17, 7, 10, 8, 15] and %rsi contains the value 10.

C code:

void y (long* arr, long b){

}

Assembly code:

13         movq    %rdi, -24 (%rbp)

14         movq    %rsi, -32 (%rbp)

15         movq    $0, -8 (%rbp)

16         jmp     .L2

17   .L4:

18         movq    -8 (%rbp), %rax

19         leaq    0 (,%rax,8), %rdx

20         movq    -24 (%rbp), %rax

21         addq    %rdx, %rax

22         movq    (%rax), %rax

23         movq    %rax, -16 (%rbp)

24         movq    -16 (%rbp), %rax


25         cmpq    -32 (%rbp), %rax

26         jge     .L3

27         movq    -32 (%rbp), %rax

28         movq    %rax, -16 (%rbp)

29   .L3:

30         _A_    $1, -8 (%rbp)

31   .L2:

32         cmpq    $_B_, -8 (%rbp)

33         jle     .L4

34         ret

(4 points) Which line between line 18 and line 30 is responsible for computing the offset of each array element in arr?

(3 points) At the first iteration of the loop (hint: that’s when the value stored in -8 (%rbp)is 0) , what is stored in %rax at the end of line 22?

(3 points) What kind of programming structure is used in this function?

a. Do-while

b. While/for

c.  Switch statement

d.  None of the above

(6 points) Fill in A and B with the proper instruction so that the function behaves as desired.

A:

B:

(4 points) Describe briefly what the condition is when updating each array element.

(4 points) What are the updated array values at the end of this function execution?

Problem 4: Microarchitecture/ISA (48 points)

You are working at Intel and are on the team for designing a new microarchitecture. Your

manager gives you components for the standard five-stage pipeline: (F)etch, (D)ecode,

(E)xecute, (M)emory and (W)riteback stages, with the same functionality as discussed in the class. The pipelined processor specification you manager give you is as follows:

(F)etch, (D)ecode, (E)xecute stages take 15 ns

The (M)emory stage takes 100 ns.

The (W)riteback stage takes 135 ns

After each stage there is a pipeline register which has a delay of 15 ns.

Part a) (12 points)

(3 points) What is the order of the 5 pipeline stages in a typical processor?

(3 points) What is the shortest possible clock period for the specification your manager gives you?

(3 points) Assuming no stalls or control dependencies of any kind, using the clock frequency you suggested, and that all the stages are occupied with instructions, how many instructions can this processor finish in 750 ns?

(3 points) At the end of which stage is the branch target resolved?

Part b) (20 points)

Now you want to design an ISA for this machine assuming the following:

5 bit address space

Memory is byte addressable

Addresses are physical addresses (i.e., no virtual memory)

Each instruction is 1-byte long; instructions can be padded with 0 at the end if needed

4 general purpose registers encoded as:

Register

Binary

r0

00

r1

01

r2

10

r3

11

Three opcodes encoded as:

Name

Opcode

Behavior

cmp

001

Performs bitwise AND on two operands

j if

010

Conditional jump

nop

011

A no-op instruction

(8 points) Encode the following program in binary, assuming the instructions start at an absolute address of 0.

0: cmp r0 r1

1: j if 3

2: nop

3: nop

(4 points) How many cycles are expected to be lost when a branch is mispredicted? Write your explanation to earn partial credit.

(4 points) Assuming full pipelining, that there are no branch mispredictions, and that all jump  instructions are not taken, how many cycles will it take to execute these instructions repeated 10 times? Show your math to earn partial credit.

(4 points) Assuming EVERY branch is mispredicted and that all jump instructions are not taken, how many cycles will it take to execute these instructions repeated 10 times? Show your math to earn partial credit.

Part c) (16 points)

Now you want to optimize the processor microarchitecture. You are told that you can split any of the stages (except the execute stage) into two stages, and each new stage will be half its original  delay. These new stages cannot be split further. ANY number of consecutive stages can also be combined together and the delay of a so-combined stage is the sum of the constituting stages.

Reminder:

●   When you split a stage into two pipeline stages, a new pipeline register must be inserted between the two new stages

●   When you combine multiple stages into one stage, the pipeline stages between the constituting stages are no longer needed.

(4 points) Suppose you combine the first 4 stages. What is the shortest possible clock period after doing so?  Show your math to earn partial credit.

(4 points) Assuming no stalls or control dependencies of any kind and all the stages are

occupied with instructions, which stage(s) do you need to combine or split so you can maximize the instructions executed per second? Write your explanation to earn partial credit.

(8 points) On top of the decisions you made for your last question, which stage(s) should you split or combine if you are also concerned with minimizing the time lost from branch mispredictions? Write your explanation to earn partial credit.

Problem 5: Cache (16 points)

For all the questions in this problem, assume that we are using a 16-bit machine with a byte-addressable memory and a N-way set-associative LRU cache (for some unknown N). The cache can hold up to 16 cache lines. Each cache line is 32 bytes (256 bits). There are 8 sets in total.

(3 points) How many bits do you need for the offset?

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

(2 points) How many cachelines are there in each set?

(8 points) The following sequence of  memory accesses generates the hits/misses as shown. Some miss/hit entries are intentionally left blank for you to figure out. The cache is initially empty. Note that  addresses are written in binary with spaces added between each 4 bits for readability — these splitting points are not necessarily the tag/index/offset boundaries.

Fill in the blanks.

#

Address

Hit/Miss

1

1100 1111 0000 0000

Miss

2

1101 1101 0010 0000

Miss

3

1101 1100 0010 0000

Miss

4

1100 1101 0001 1011

Miss

5

1100 1111 0000 0011

Hit

6

1100 1111 1001 0001

Miss

7

1100 1101 0000 1111

Hit

8

1101 1100 0000 0000

Miss

9

1100 1111 0001 1111

Miss

10

1111 1111 0010 0000

Miss

11

1101 1101 0010 0000

Miss

12

0101 1001 0011 0100

Miss

13

1101 1101 0010 0100

Hit

Problem 6: Virtual Memory (12 points + 4 points extra credit)

Assume a byte addressable memory with the following characteristics:

1.    Size of the virtual memory is 16 MB (1 MB = 220  B)

2.   Size of the physical memory is 4 MB

3.   Page size is 256 Bytes

4.   It uses one-level page table

Format of the PTE is shown below:

(3 points) How many bits do you need to represent the virtual page number (VPN)

(3 points) How many bits do you need to represent the physical page number (PPN)

(3 points) How many PTEs can you store in a page?

(3 points) How many pages does the page table occupy?

(4 points extra credit) Now we add a TLB to the machine above. The TLB has 16 entries and is direct-mapped. Which bits in the virtual address are used to index the TLB?





热门主题

课程名

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
站长地图