From a468512e16e53a09e8d483a2594d55521012d89a Mon Sep 17 00:00:00 2001 From: dpturnbull Date: Sat, 17 Nov 2012 00:33:09 -0500 Subject: [PATCH] Debugging code --- FirstFit.java | 71 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/FirstFit.java b/FirstFit.java index e0a3c5b..ecff746 100644 --- a/FirstFit.java +++ b/FirstFit.java @@ -22,10 +22,12 @@ class FirstFit implements baseAlgorithm noJobs=0, s1=0, compMemTest=0, + jobLoaded=0, tableEntries=1; private int[] tempVal = new int[6]; private int[][] memTable = new int[memSize+2][6]; private int[] memory = new int[memSize]; + private Job[] jobArray = new Job[memoryManagement.JOBAMOUNT+10]; //this is a no argument constructor public FirstFit() @@ -63,6 +65,15 @@ class FirstFit implements baseAlgorithm System.exit(0); } + + + + + + //this will loop until job is loaded into memory + do + { + //this section looks for a place to put the new job do { @@ -79,6 +90,7 @@ class FirstFit implements baseAlgorithm memTable[s1][5] = 1; Job newJob = new Job(jobTime, jobId, jobSize, memTable[s1][2], deallocateMethod, this); fillMemory(jobId, jobSize, memTable[s1][2]); + jobArray[jobId - 1] = newJob; newJob.start(); memTable[s1+1][0] = 0; memTable[s1+1][1] = 0; @@ -87,7 +99,8 @@ class FirstFit implements baseAlgorithm memTable[s1+1][4] = memSize-memTable[s1+1][2]; memTable[s1+1][5] = -1; tableEntries++; - System.out.println(toString()); + jobLoaded=1; + System.out.println("add job "+jobId+toString()); s1=memSize*2; } //runs after the first job and if the only available slot is at the end of memory @@ -101,6 +114,7 @@ class FirstFit implements baseAlgorithm memTable[s1][5] = 1; Job newJob = new Job(jobTime, jobId, jobSize, memTable[s1][2], deallocateMethod, this); fillMemory(jobId, jobSize, memTable[s1][2]); + jobArray[jobId - 1] = newJob; newJob.start(); memTable[s1+1][0] = 0; memTable[s1+1][1] = 0; @@ -109,7 +123,8 @@ class FirstFit implements baseAlgorithm memTable[s1+1][4] = memSize-memTable[s1+1][2]; memTable[s1+1][5] = -1; tableEntries++; - System.out.println(toString()); + jobLoaded=1; + System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -121,8 +136,10 @@ class FirstFit implements baseAlgorithm memTable[s1][5] = 1; Job newJob = new Job(jobTime, jobId, jobSize, memTable[s1][2], deallocateMethod, this); fillMemory(jobId, jobSize, memTable[s1][2]); + jobArray[jobId - 1] = newJob; newJob.start(); - System.out.println(toString()); + jobLoaded=1; + System.out.println("add job "+jobId+toString()); s1=memSize*2; } else @@ -130,15 +147,20 @@ class FirstFit implements baseAlgorithm s1++; } }while(s1