Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
Question
Book Icon
Chapter 6.5, Problem 6.18PP

A.

Program Plan Intro

Given Information:

The heart of the recent hit game SimAquarium is a tight loop that calculates the average position of 256 algae. One needs to determine the cache performance on a machine that has a 1024 byte direct mapped data cache with 16 byte blocks (B=16).

The definition for the game is mentioned below:

//Declare structure algae_position

struct algae_position{

int x;

int y;

};

//declare grid

struct algae_position grid[16][16];

//variable declaration

int total_x=0, total_y=0;

int i,j;

//traverse through grid to add x

for(i=0;i<16;i++)

{

for(j=0;j<16;j++)

{

total_x+= grid[i][j].x;

}

}

//traverse through grid to add y

for(i=0;i<16;i++)

{

for(j=0;j<16;j++)

{

total_y+= grid[i][j].y;

}

}

B.

Program Plan Intro

Given Information:

The heart of the recent hit game SimAquarium is a tight loop that calculates the average position of 256 algae. One needs to determine the cache performance on a machine that has a 1024 byte direct mapped data cache with 16 byte blocks (B=16).

The definition for the game is mentioned below:

//Declare structure algae_position

struct algae_position{

int x;

int y;

};

//declare grid

struct algae_position grid[16][16];

//variable declaration

int total_x=0, total_y=0;

int i,j;

//traverse through grid to add x

for(i=0;i<16;i++)

{

for(j=0;j<16;j++)

{

total_x+= grid[i][j].x;

}

}

//traverse through grid to add y

for(i=0;i<16;i++)

{

for(j=0;j<16;j++)

{

total_y+= grid[i][j].y;

}

}

C.

Explanation of Solution

Miss rate:

It is observed that for all 256 reads, 128 of them are misses. Similarly, for the second loops another 128 reads will be missed.

Hence, total number of misses= 128+128=256

Hence,

miss rate=(numberofmiss/totalreads)×100%

Blurred answer
Students have asked these similar questions
Whentheuserenters!!,themostrecentcommandinthehistoryisexecuted.In the example above, if the user entered the command: Osh> !! The ‘ls -l’ command should be executed and echoed on user’s screen. The command should also be placed in the history buffer as the next command. Whentheuserentersasingle!followedbyanintegerN,theNthcommandin the history is executed. In the example above, if the user entered the command: Osh> ! 3 The ‘ps’ command should be executed and echoed on the user’s screen. The command should also be placed in the history buffer as the next command. Error handling: The program should also manage basic error handling. For example, if there are no commands in the history, entering !! should result in a message “No commands in history.” Also, if there is no command corresponding to the number entered with the single !, the program should output "No such command in history."
Activity No. Activity Time (weeks) Immediate Predecessors 1 Requirements collection 3 2 Requirements structuring 4 1 3 Process analysis 3 2 4 Data analysis 3 2 5 Logical design 50 3,4 6 Physical design 5 5 7 Implementation 6 6 c. Using the information from part b, prepare a network diagram. Identify the critical path.
2. UNIX Shell and History Feature [20 points] This question consists of designing a C program to serve as a shell interface that accepts user commands and then executes each command in a separate process. A shell interface gives the user a prompt, after which the next command is entered. The example below illustrates the prompt osh> and the user's next command: cat prog.c. The UNIX/Linux cat command displays the contents of the file prog.c on the terminal using the UNIX/Linux cat command and your program needs to do the same. osh> cat prog.c The above can be achieved by running your shell interface as a parent process. Every time a command is entered, you create a child process by using fork(), which then executes the user's command using one of the system calls in the exec() family (as described in Chapter 3). A C program that provides the general operations of a command-line shell can be seen below. #include #include #define MAX LINE 80 /* The maximum length command */ { int…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage