Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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?
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY