mirror of
https://github.com/bspeice/itcs3146-project
synced 2024-12-21 22:28:14 -05:00
Final Working Code
This commit is contained in:
parent
33317f3f3a
commit
582293d02c
@ -102,7 +102,6 @@ class FirstFit implements baseAlgorithm
|
|||||||
memTable[s1+1][5] = -1;
|
memTable[s1+1][5] = -1;
|
||||||
tableEntries++;
|
tableEntries++;
|
||||||
jobLoaded=1;
|
jobLoaded=1;
|
||||||
System.out.println("add job "+jobId+toString());
|
|
||||||
s1=memSize*2;
|
s1=memSize*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +127,6 @@ class FirstFit implements baseAlgorithm
|
|||||||
memTable[s1+1][5] = -1;
|
memTable[s1+1][5] = -1;
|
||||||
tableEntries++;
|
tableEntries++;
|
||||||
jobLoaded=1;
|
jobLoaded=1;
|
||||||
System.out.println("add job "+jobId+toString());
|
|
||||||
s1=memSize*2;
|
s1=memSize*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +143,6 @@ class FirstFit implements baseAlgorithm
|
|||||||
jobArray[jobId - 1] = newJob;
|
jobArray[jobId - 1] = newJob;
|
||||||
newJob.start();
|
newJob.start();
|
||||||
jobLoaded=1;
|
jobLoaded=1;
|
||||||
System.out.println("add job "+jobId+toString());
|
|
||||||
s1=memSize*2;
|
s1=memSize*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +167,6 @@ class FirstFit implements baseAlgorithm
|
|||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
System.out.println("Could not allocate job with ID " + jobId);
|
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@ -187,19 +183,14 @@ class FirstFit implements baseAlgorithm
|
|||||||
int deallocates1=0;
|
int deallocates1=0;
|
||||||
jobSize = jSize;
|
jobSize = jSize;
|
||||||
startLoc = beginningLocation;
|
startLoc = beginningLocation;
|
||||||
System.out.println("jSize= "+jobSize+" startLoc= "+startLoc);
|
|
||||||
//s1=0;
|
//s1=0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(memTable[deallocates1][2] == startLoc)
|
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][0] = 0;
|
||||||
memTable[deallocates1][1] = 0;
|
memTable[deallocates1][1] = 0;
|
||||||
memTable[deallocates1][5] = 0;
|
memTable[deallocates1][5] = 0;
|
||||||
System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]);
|
|
||||||
System.out.println(toString());
|
|
||||||
noJobs--;
|
noJobs--;
|
||||||
deallocates1=memSize*2;
|
deallocates1=memSize*2;
|
||||||
}
|
}
|
||||||
@ -214,7 +205,6 @@ class FirstFit implements baseAlgorithm
|
|||||||
//this method compacts the memory
|
//this method compacts the memory
|
||||||
public void compMem()
|
public void compMem()
|
||||||
{
|
{
|
||||||
//System.out.println("Compacting Memory");
|
|
||||||
compMemTest=tableEntries;
|
compMemTest=tableEntries;
|
||||||
for(int c=0; c<=compMemTest; c++)
|
for(int c=0; c<=compMemTest; c++)
|
||||||
{
|
{
|
||||||
|
11
NextFit.java
11
NextFit.java
@ -109,7 +109,6 @@ class NextFit implements baseAlgorithm
|
|||||||
positionToCompress=currentPosition;
|
positionToCompress=currentPosition;
|
||||||
tableEntries++;
|
tableEntries++;
|
||||||
jobLoaded=1;
|
jobLoaded=1;
|
||||||
System.out.println("add job "+jobId+toString());
|
|
||||||
s1=memSize*2;
|
s1=memSize*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +136,6 @@ class NextFit implements baseAlgorithm
|
|||||||
currentPosition++;
|
currentPosition++;
|
||||||
jobLoaded=1;
|
jobLoaded=1;
|
||||||
positionToCompress=currentPosition;
|
positionToCompress=currentPosition;
|
||||||
System.out.println("add job "+jobId+toString());
|
|
||||||
s1=memSize*2;
|
s1=memSize*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +154,6 @@ class NextFit implements baseAlgorithm
|
|||||||
currentPosition++;
|
currentPosition++;
|
||||||
jobLoaded=1;
|
jobLoaded=1;
|
||||||
positionToCompress=currentPosition;
|
positionToCompress=currentPosition;
|
||||||
System.out.println("add job "+jobId+toString());
|
|
||||||
s1=memSize*2;
|
s1=memSize*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,7 +186,6 @@ class NextFit implements baseAlgorithm
|
|||||||
|
|
||||||
} catch (Exception e)
|
} 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
|
//this method removes a job it does not check to see if the job exisits
|
||||||
public void deallocate(int jSize, int beginningLocation)
|
public void deallocate(int jSize, int beginningLocation)
|
||||||
{
|
{
|
||||||
System.out.println("jSize= "+jSize+" startLoc= "+beginningLocation);
|
|
||||||
synchronized(memTable){
|
synchronized(memTable){
|
||||||
int deallocates1=0;
|
int deallocates1=0;
|
||||||
jobSize = jSize;
|
jobSize = jSize;
|
||||||
startLoc = beginningLocation;
|
startLoc = beginningLocation;
|
||||||
System.out.println("jSize= "+jobSize+" startLoc= "+startLoc);
|
|
||||||
//s1=0;
|
//s1=0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(memTable[deallocates1][2] == startLoc)
|
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][0] = 0;
|
||||||
memTable[deallocates1][1] = 0;
|
memTable[deallocates1][1] = 0;
|
||||||
memTable[deallocates1][5] = 0;
|
memTable[deallocates1][5] = 0;
|
||||||
System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]);
|
|
||||||
System.out.println(toString());
|
|
||||||
noJobs--;
|
noJobs--;
|
||||||
deallocates1=memSize*2;
|
deallocates1=memSize*2;
|
||||||
}
|
}
|
||||||
@ -234,7 +224,6 @@ class NextFit implements baseAlgorithm
|
|||||||
//this method compacts the memory
|
//this method compacts the memory
|
||||||
public void compMem()
|
public void compMem()
|
||||||
{
|
{
|
||||||
//System.out.println("Compacting Memory");
|
|
||||||
compMemTest=tableEntries;
|
compMemTest=tableEntries;
|
||||||
for(int c=0; c<=compMemTest; c++)
|
for(int c=0; c<=compMemTest; c++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user