
Study the two functions given below. Both use the same array declared as: static int data[256*256*8];
void function1()
{
int i;
int j;
for (i = 0; i < 32; i++)
for (j = 0; j < 256; j++)
data[j] = i;
}
void function2()
{
int i;
int j;
for (i = 0; i < 32; i++)
for (j = 0; j < 256; j++)
data[j*2048] = i;
}
Instructions:
Assume the following behaviors in a virtual memory system. Reading or writing physical
memory requires 50 nanoseconds. Reading or writing disk writing 10 milliseconds. Page
size is 8 kilobytes. Presume that the program has 1 megabyte of physical memory
available. You may consider everything except the array access itself to take no time.
You should also assume that the first 1 megabyte of the array is in physical memory ini-
tially. You may ignore any memory used by the program or stack to execute these func-
tions. Using this information, answer the following questions. In each case, show the
work you use to calculate the answer. Give your answer in a reasonable unit.
a) How many bytes of of virtual memory are necessary to hold the entire array?
b) How many pages are necessary to hold the entire array?
c) Assuming an int requires 4 bytes, which elements of the array will start in physical
memory?
d) Just considering virtual memory access time, how long will it take for function1() to
execute?
e) Just considering virtual memory access time, how long will it take for function2() to
execute? Remember to account for both read and write activity.

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- In C Programming: You will need all the functions from the previous assignment, as well as the structure course:• Department (string, 15 characters)• Course number (integer, 4 digits, leading 0 if necessary)• Course title (string, 30 characters)• Credits (short, 1 digit) Write a function saveAllCoursesText() which receives an array of course pointers and the array’s size, then outputs the content of the array in text format to a file named “courses.txt”.• Save the entire structure on 1 line (all the members of the structure should be saved in 1 fprintf() command)arrow_forwardc++problemarrow_forwardProgram in C++arrow_forward
- Using c++arrow_forwardC++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.arrow_forwardDescribe how to pass an array as a parameter to a function.arrow_forward
- Complete this code using Python m1 = [] #Matrix 1m2 = [] #Matrix 2#Write a function that will return the addition of Matrix A and B.#Create a new matrix C that will hold the addtion result of Matrix A and B (A+B).#Return the resultant matrix Cdef addMatrix(A,B):#Write your code here#Write a function that will return the subtraction of Matrix B from A.#Create a new matrix C that will hold the substraction result of Matrix B from A (A-B).#Return the resultant matrix Cdef subsMatrix(A,B):#Write your code here#Write a function that will return the multiplication of Matrix A and B.#Create a new matrix C that will hold the multiplication result of Matrix A and B (A*B).#Keep in mind,in order to perform matrix multiplication, the number of columns in Matrix A must be equal to the number of columns in Matrix B. #Return the resultant matrix Cdef multipyMatrix(A,B):#Write your code here#Write a function that will transform matrix A to the transpose of matrix A.#The transpose of a matrix means…arrow_forwardWhat does "base address of an array" mean, and how does it come into play in a function call?arrow_forwardC++arrow_forward
- One dimension array in C:Create an array of 100 integer elements and initialize the array elements to zero.Populate the array (using a for loop) with the values 10,20,30,..., 990,1000.Write code (using for loops) to sum all the elements and output the sum to the screen. without using #definearrow_forwardc++ programming Write a function named maxCols which stores the maximum value in each row of a 3x3 2D array into a 1D array. This function should accept a 3x3 2D array, a 1D array and the size of each dimension as parameters. Example Calling maxCols with this 2D array:3 7 2 9 3 6 8 5 6 Results in the 1D array storing the values 7,9,8.arrow_forwardWhat does the phrase "base address of an array" relate to, and how does it come to be utilized in a call to a function?arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





