runtime
= (Physical Memory / PAGE_SIZE)
/ READS_PER_SECOND
eg:
160seconds = (128MB
/ (8KB/PAGE))
/ 100
NB: This only runs under Java 2.
CF: Same program in C: time_disk.c
*/
import java.io.*;
import java.util.*;
import Extensions.*;
public class Test implements Runnable {
static int
MAX_FILE_SIZE = 1024*1024*1024;
static int
PAGE_SIZE = 8192;
static int
MAX_PAGES = (MAX_FILE_SIZE/PAGE_SIZE);
static int
MAX_THREADS = 512;
static int
MAX_DENSITY = 100;
static int
MAX_READS;
static int[]
hits = new int[MAX_PAGES];
static int[]
density = new int[MAX_DENSITY];
static String
path="/tmp/time_disk0.tmp";
static int
spinTime = 0, runtime = 10, nThreads = 1;
static int
iterations = 1;
static boolean  setConcurrency = false;
static int[]
nProcessed;
static boolean  DEBUG = false;
static Thread[] threads;
static boolean  stop = false;
static native void pthread_setconcurrency(int i);
static {System.loadLibrary("PThreadsInterface");}
// System.out.println("Loaded");}
Random ran;
int
me;
public void run() {
int
err;
long
length;
byte[]
b = new byte[2];
RandomAccessFile
fd = null;
long
fileOffset;
Thread
self = Thread.currentThread();
try {
fd = new RandomAccessFile(path, "r");
length = fd.length();
for (int i = 0; i < MAX_READS; i++) {
if (stop)
break;
fileOffset =
Math.abs((ran.nextInt() * PAGE_SIZE) %
length);
hits[(int) fileOffset / PAGE_SIZE]++;
//if (DEBUG)
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home