static char *workingSet; // The memory this program wants to acquire. static int soFar; // How many pages the program has so far. static sthread_t refreshThread; // This thread touches the pages we have in memory, to keep them recently used. void refresh () { int i; while (1) { // Keep every page in memory recently used. for (i = 0; i < soFar; i += PAGESIZE) workingSet[i] = 0; } } int main (int argc, char **argv) { // Allocate a giant array. workingSet = malloc(ARRAYSIZE); soFar = 0; // Create a thread to keep our pages in memory, once they get there. thread_create(&refreshThread, refresh, 0); // Touch every page to bring it into memory. for (; soFar < ARRAYSIZE; soFar += PAGESIZE) workingSet[soFar] = 0; // Now that everything is in memory, run computation. // ... }