huge - for (i=0; i<NumPages; i++) { sparse[i][0]=i; }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * huge.c * * Tests the VM system by accessing a large array (sparse) that * cannot fit into memory. * * When the VM system assignment is done, your system should be able * to run this successfully. */ #include <stdio.h> #include <stdlib.h> #define PageSize 4096 #define NumPages 512 int sparse[NumPages][PageSize]; /* use only the first element in the row */ int main() { int i,j; printf("Entering the huge program - I will stress test your VM\n"); /* move number in so that sparse[i][0]=i */
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (i=0; i<NumPages; i++) { sparse[i][0]=i; } printf("stage [1] done\n"); /* increment each location 5 times */ for (j=0; j<5; j++) { for (i=0; i<NumPages; i++) { sparse[i][0]++; } printf("stage [2.%d] done\n", j); } printf("stage [2] done\n"); /* check if the numbers are sane */ for (i=NumPages-1; i>=0; i--) { if (sparse[i][0]!=i+5) { printf("BAD NEWS!!! - your VM mechanism has a bug!\n"); exit(1); } } printf("You passed!\n"); return 0; }...
View Full Document

This note was uploaded on 11/10/2009 for the course CS 536 taught by Professor Lums during the Spring '09 term at Indiana.

Ask a homework question - tutors are online