4. In this question, we consider the relative performance obtained by running a particular with various caches installed between the memory and the CPU. program Consider the following C function: 1 char a [512], b[512] add arrays (O { register int i; for (i = 0; i < 511; i = i+1) { a[i+1] = a[i] + b[i]; // Work!! } (The register keyword tells the C compiler to reserve a register for the variable i; let's assume it keeps i in RO. What does this mean for us? The variable i is not stored in main memory- it's stored in the CPU; this mean that it never has to be pulled from main memory into the cache when the CPU accesses it. The char keyword allocates character arrays at fixed locations in memory, using 1 byte per character.) Recall that in C, an array is a contiguous chunk of memory. Therefore, in this code, array a starts at some address (say, 0×00A), and ends at (start address) + n-sizeof (char) address, where n is the number of elements and sizeof (char) is the number of bytes a char takes in memory (and in this example, we're using char because it's 1 byte and makes calculating simple!). For the following questions, assume that the memory can read or write 1 byte at a time. (a) Suppose, when the code is actually run, the array a starts at physical memory address 0x0100, and b is right after (that is, adjacent to) a in memory. What are the physical addresses of the first 5 elements of a? The first 5 elements of b?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
4. In this question, we consider the relative performance obtained by running a particular program
with various caches installed between the memory and the CPU.
Consider the following C function:
char a [512], b[512]
3 add_arrays () {
register int i;
for (i = 0; i < 511; i = i+1) {
a[i+1] = a [i] + b[i]; // Work!!
9 }
(The register keyword tells the C compiler to reserve a register for the variable i; let's assume
it keeps i in RO. What does this mean for us? The variable i is not stored in main memory-
it's stored in the CPU; this mean that it never has to be pulled from main memory into the
cache when the CPU accesses it.
The char keyword allocates character arrays at fixed locations in memory, using 1 byte per
character.)
Recall that in C, an array is a contiguous chunk of memory. Therefore, in this code, array a
starts at some address (say, 0x00A), and ends at (start address) + n'sizeof (char) address,
where n is the number of elements and sizeof (char) is the number of bytes a char takes
in memory (and in this example, we're using char because it's 1 byte and makes calculating
simple!).
For the following questions, assume that the memory can read or write 1 byte at a time.
(a) Suppose, when the code is actually run, the array a starts at physical memory address
Ox0100, and b is right after (that is, adjacent to) a in memory. What are the physical
addresses of the first 5 elements of a? The first 5 elements of b?
Transcribed Image Text:4. In this question, we consider the relative performance obtained by running a particular program with various caches installed between the memory and the CPU. Consider the following C function: char a [512], b[512] 3 add_arrays () { register int i; for (i = 0; i < 511; i = i+1) { a[i+1] = a [i] + b[i]; // Work!! 9 } (The register keyword tells the C compiler to reserve a register for the variable i; let's assume it keeps i in RO. What does this mean for us? The variable i is not stored in main memory- it's stored in the CPU; this mean that it never has to be pulled from main memory into the cache when the CPU accesses it. The char keyword allocates character arrays at fixed locations in memory, using 1 byte per character.) Recall that in C, an array is a contiguous chunk of memory. Therefore, in this code, array a starts at some address (say, 0x00A), and ends at (start address) + n'sizeof (char) address, where n is the number of elements and sizeof (char) is the number of bytes a char takes in memory (and in this example, we're using char because it's 1 byte and makes calculating simple!). For the following questions, assume that the memory can read or write 1 byte at a time. (a) Suppose, when the code is actually run, the array a starts at physical memory address Ox0100, and b is right after (that is, adjacent to) a in memory. What are the physical addresses of the first 5 elements of a? The first 5 elements of b?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY