Final Working Code

This commit is contained in:
dpturnbull 2012-11-23 20:05:29 -05:00
parent 33317f3f3a
commit 582293d02c
3 changed files with 11 additions and 21 deletions

View File

@ -102,7 +102,6 @@ class FirstFit implements baseAlgorithm
memTable[s1+1][5] = -1;
tableEntries++;
jobLoaded=1;
System.out.println("add job "+jobId+toString());
s1=memSize*2;
}
}
@ -128,7 +127,6 @@ class FirstFit implements baseAlgorithm
memTable[s1+1][5] = -1;
tableEntries++;
jobLoaded=1;
System.out.println("add job "+jobId+toString());
s1=memSize*2;
}
}
@ -145,7 +143,6 @@ class FirstFit implements baseAlgorithm
jobArray[jobId - 1] = newJob;
newJob.start();
jobLoaded=1;
System.out.println("add job "+jobId+toString());
s1=memSize*2;
}
}
@ -170,7 +167,6 @@ class FirstFit implements baseAlgorithm
} catch (Exception e)
{
System.out.println("Could not allocate job with ID " + jobId);
}
//}
}
@ -187,19 +183,14 @@ class FirstFit implements baseAlgorithm
int deallocates1=0;
jobSize = jSize;
startLoc = beginningLocation;
System.out.println("jSize= "+jobSize+" startLoc= "+startLoc);
//s1=0;
do
{
if(memTable[deallocates1][2] == startLoc)
{
System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]);
System.out.println(startLoc+" removed job "+memTable[deallocates1][0]);
memTable[deallocates1][0] = 0;
memTable[deallocates1][1] = 0;
memTable[deallocates1][5] = 0;
System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]);
System.out.println(toString());
noJobs--;
deallocates1=memSize*2;
}
@ -214,7 +205,6 @@ class FirstFit implements baseAlgorithm
//this method compacts the memory
public void compMem()
{
//System.out.println("Compacting Memory");
compMemTest=tableEntries;
for(int c=0; c<=compMemTest; c++)
{

View File

@ -109,7 +109,6 @@ class NextFit implements baseAlgorithm
positionToCompress=currentPosition;
tableEntries++;
jobLoaded=1;
System.out.println("add job "+jobId+toString());
s1=memSize*2;
}
}
@ -137,7 +136,6 @@ class NextFit implements baseAlgorithm
currentPosition++;
jobLoaded=1;
positionToCompress=currentPosition;
System.out.println("add job "+jobId+toString());
s1=memSize*2;
}
}
@ -156,7 +154,6 @@ class NextFit implements baseAlgorithm
currentPosition++;
jobLoaded=1;
positionToCompress=currentPosition;
System.out.println("add job "+jobId+toString());
s1=memSize*2;
}
}
@ -189,7 +186,6 @@ class NextFit implements baseAlgorithm
} catch (Exception e)
{
System.out.println("Could not allocate job with ID " + jobId);
}
//}
}
@ -202,24 +198,18 @@ class NextFit implements baseAlgorithm
//this method removes a job it does not check to see if the job exisits
public void deallocate(int jSize, int beginningLocation)
{
System.out.println("jSize= "+jSize+" startLoc= "+beginningLocation);
synchronized(memTable){
int deallocates1=0;
jobSize = jSize;
startLoc = beginningLocation;
System.out.println("jSize= "+jobSize+" startLoc= "+startLoc);
//s1=0;
do
{
if(memTable[deallocates1][2] == startLoc)
{
System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]);
System.out.println(startLoc+" removed job "+memTable[deallocates1][0]);
memTable[deallocates1][0] = 0;
memTable[deallocates1][1] = 0;
memTable[deallocates1][5] = 0;
System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]);
System.out.println(toString());
noJobs--;
deallocates1=memSize*2;
}
@ -234,7 +224,6 @@ class NextFit implements baseAlgorithm
//this method compacts the memory
public void compMem()
{
//System.out.println("Compacting Memory");
compMemTest=tableEntries;
for(int c=0; c<=compMemTest; c++)
{

11
log.txt
View File

@ -0,0 +1,11 @@
Memory Management Log
---------------------------
Job Amount: 200
Memory Size: 100
---------------------------
Final Times (All times in milliseconds)
Threaded time: 0
Best fit time: 0
Worst fit time: 0
First fit time: 28094
Next fit time: 26375