1. Homepage
  2. Exam
  3. [2021] COMP1411 Introduction to Computer Systems - Q6 Program Execution Procedure

[2021] COMP1411 Introduction to Computer Systems - Q6 Program Execution Procedure

This question has been solved
Engage in a Conversation

Question 6. [25 marks]


CourseNana.COM

Given the program written in the Y86-64 assembly language. CourseNana.COM

  CourseNana.COM

irmovq $1, %rsi CourseNana.COM

irmovq $4, %rdi CourseNana.COM

irmovq $0, %rax CourseNana.COM

addq %rsi, %rax CourseNana.COM

L0: CourseNana.COM

rrmovq %rax, %rbp CourseNana.COM

andq %rsi, %rbp CourseNana.COM

nop CourseNana.COM

nop CourseNana.COM

nop CourseNana.COM

je .L1 CourseNana.COM

addq %rbx, %rcx CourseNana.COM

addq %rsi, %rcx CourseNana.COM

addq %rdi, %rcx CourseNana.COM

nop jmp .L2 CourseNana.COM

L1: CourseNana.COM

irmovq $5, %rcx CourseNana.COM

andq %rdi, %rcx CourseNana.COM

addq %rsi, %rbx CourseNana.COM

subq %rbx, %rcx CourseNana.COM

L2: CourseNana.COM

addq %rsi, %rax CourseNana.COM

rrmovq %rax, %rbp CourseNana.COM

subq %rdi, %rbp CourseNana.COM

jle .L0 CourseNana.COM

ret CourseNana.COM

  CourseNana.COM

Assume that all the instructions are stored in continuous addresses of the main memory, and the main memory is partitioned into blocks with each block has size of 16 bytes. Assume that the first instruction is exactly at the beginning of block 1 (blocks are numbered 1, 2, 3, 4, …, according to increasing addresses). CourseNana.COM

  CourseNana.COM

The system has a cache that can hold 3 blocks. When the CPU loads an instruction from the main memory, it first checks if the block containing the required instruction is in the cache or not. If the block is in the cache, we say there is a cache hit; if otherwise the block is not in the cache, we say there is a cache miss, and the CPU will fetch the block(s) containing the required instruction from the main memory and put the block in the cache. At the beginning of the program execution, the cache is empty. CourseNana.COM

  CourseNana.COM

If the cache is full, i.e, the cache is holding 3 blocks and a new block will be loaded into the cache, one of the 3 existing blocks will be replaced out of the cache. Assume that Least Recently Used (LRU) is applied when replacing blocks. By LRU, the block with the oldest access time (among the 3 blocks) will be evicted out of the cache. CourseNana.COM

  CourseNana.COM

6(a) Show the partition of blocks, and list the sequence of block numbers that are accessed during the execution of the program. CourseNana.COM

Main behavior of the program should be provided to support your given block access sequence. CourseNana.COM

Note that if multiple instructions belonging to the same block are consecutively executed, we treat the execution of these instructions as a single access to the corresponding block. CourseNana.COM

[14 marks] CourseNana.COM

  CourseNana.COM

6(b) Draw the history of cache states during the program execution. [11 marks] CourseNana.COM

An example with 2 block accesses is given below: the vertical boxes represents a cache state with some blocks in the cache; an arrow represents the behavior of accessing a block, changing the cache state from the left one to the right one. CourseNana.COM

Write the accessed block number above the arrow, and write out whether the access to the block is a cache hit (H) or miss (M) below the arrow. CourseNana.COM

  CourseNana.COM

  CourseNana.COM

CourseNana.COM

Get the Solution to This Question

WeChat WeChat
Whatsapp WhatsApp
The Hong Kong Polytechnic University代写,COMP1411代写,Introduction to Computer Systems代写,Assembly Language代写,The Hong Kong Polytechnic University代编,COMP1411代编,Introduction to Computer Systems代编,Assembly Language代编,The Hong Kong Polytechnic University代考,COMP1411代考,Introduction to Computer Systems代考,Assembly Language代考,The Hong Kong Polytechnic Universityhelp,COMP1411help,Introduction to Computer Systemshelp,Assembly Languagehelp,The Hong Kong Polytechnic University作业代写,COMP1411作业代写,Introduction to Computer Systems作业代写,Assembly Language作业代写,The Hong Kong Polytechnic University编程代写,COMP1411编程代写,Introduction to Computer Systems编程代写,Assembly Language编程代写,The Hong Kong Polytechnic Universityprogramming help,COMP1411programming help,Introduction to Computer Systemsprogramming help,Assembly Languageprogramming help,The Hong Kong Polytechnic Universityassignment help,COMP1411assignment help,Introduction to Computer Systemsassignment help,Assembly Languageassignment help,The Hong Kong Polytechnic Universitysolution,COMP1411solution,Introduction to Computer Systemssolution,Assembly Languagesolution,