hi
i have the problem in this program
[CODE=java]import java.io.*;
import java.io.InputSt ream;
import java.io.OutputS tream;
import java.io.FileInp utStream;
import java.io.FileOut putStream;
import java.io.FileRea der;
import java.io.FileNot FoundException;
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class placement{
public static void main(String[]args) throws FileNotFoundExc eption
{
String internalFragmen tation;
String externalFragmen tation;
int memory,dummycou nt;
int process;
int[] bestfit,worstfi t,nextfit,first fit;
Scanner iFile= new Scanner(new FileReader("pro cesses.txt"));
Scanner inFile1= new Scanner(new FileReader("mem ory.txt"));
dummycount=0;
while (inFile1.hasNex t())
{
memory = inFile1.nextInt ();
dummycount=dumm ycount+1;
}
firstfit =new int [dummycount];
inFile1.close() ;
System.out.prin tln("------For FirstFit algorithm---------");
inFile1= new Scanner(new FileReader("mem ory.txt"));
dummycount=0;
while (iFile.hasNext( ))
{inFile1= new Scanner(new FileReader("mem ory.txt"));
process = iFile.nextInt() ;
while (inFile1.hasNex t())
{
memory = inFile1.nextInt ();
if ((memory >=process)&&(du mmycount< firstfit.length )&&(firstfit[dummycount]==0))
{
firstfit[dummycount]=process;
System.out.prin tln("memory partition" " " memory " will accomodate process that need" " " +process);
}
}
dummycount++;
inFile1.close() ;
}
iFile.close();
System.out.prin tln("------For BestFit algorithm---------");
nextfit =new int [dummycount];
//System.out.prin tln("------For NextFit algorithm---------");
dummycount=0;
iFile= new Scanner(new FileReader("pro cesses.txt"));
while (iFile.hasNext( ))
{
process = iFile.nextInt() ;
inFile1= new Scanner(new FileReader("mem ory.txt"));
while (inFile1.hasNex t())
{
memory = inFile1.nextInt ();
if ((memory >=process)&&(du mmycount< nextfit.length) &&(nextfit[dummycount]==0))
{
nextfit[dummycount]=process;
System.out.prin tln("memory partition" " " memory " will accomodate process that need" " " +process);
}
}
dummycount++;
}
System.out.prin tln("dummycount " +" "+dummycoun t);
inFile1.close() ;
iFile.close();
System.out.prin tln("------For WorstFit algorithm---------");
}
} [/CODE]
iam work at JSDK 1.6
the problem is not result the out put ????
the algorithm is
first fi that said :
allocate the first hole that is big enough .searching can start either at the beginning of the set holes or where the previous first fit search ended.wec can stop searching as soon as we fnd a large enough free hole.
best fit that said :
allocate the smallest hole that is big enough (the block that is the closet in size ). we must search the entire list ,unless the list is kept ordered by size
worst fit that said:
allocate the biggest hole that is big enough (the block that is the closet in size ). we must search the entire list ,unless the list is kept ordered by size
so
i wont to enter the process and saved it on to memory txt
help me
i have the problem in this program
[CODE=java]import java.io.*;
import java.io.InputSt ream;
import java.io.OutputS tream;
import java.io.FileInp utStream;
import java.io.FileOut putStream;
import java.io.FileRea der;
import java.io.FileNot FoundException;
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class placement{
public static void main(String[]args) throws FileNotFoundExc eption
{
String internalFragmen tation;
String externalFragmen tation;
int memory,dummycou nt;
int process;
int[] bestfit,worstfi t,nextfit,first fit;
Scanner iFile= new Scanner(new FileReader("pro cesses.txt"));
Scanner inFile1= new Scanner(new FileReader("mem ory.txt"));
dummycount=0;
while (inFile1.hasNex t())
{
memory = inFile1.nextInt ();
dummycount=dumm ycount+1;
}
firstfit =new int [dummycount];
inFile1.close() ;
System.out.prin tln("------For FirstFit algorithm---------");
inFile1= new Scanner(new FileReader("mem ory.txt"));
dummycount=0;
while (iFile.hasNext( ))
{inFile1= new Scanner(new FileReader("mem ory.txt"));
process = iFile.nextInt() ;
while (inFile1.hasNex t())
{
memory = inFile1.nextInt ();
if ((memory >=process)&&(du mmycount< firstfit.length )&&(firstfit[dummycount]==0))
{
firstfit[dummycount]=process;
System.out.prin tln("memory partition" " " memory " will accomodate process that need" " " +process);
}
}
dummycount++;
inFile1.close() ;
}
iFile.close();
System.out.prin tln("------For BestFit algorithm---------");
nextfit =new int [dummycount];
//System.out.prin tln("------For NextFit algorithm---------");
dummycount=0;
iFile= new Scanner(new FileReader("pro cesses.txt"));
while (iFile.hasNext( ))
{
process = iFile.nextInt() ;
inFile1= new Scanner(new FileReader("mem ory.txt"));
while (inFile1.hasNex t())
{
memory = inFile1.nextInt ();
if ((memory >=process)&&(du mmycount< nextfit.length) &&(nextfit[dummycount]==0))
{
nextfit[dummycount]=process;
System.out.prin tln("memory partition" " " memory " will accomodate process that need" " " +process);
}
}
dummycount++;
}
System.out.prin tln("dummycount " +" "+dummycoun t);
inFile1.close() ;
iFile.close();
System.out.prin tln("------For WorstFit algorithm---------");
}
} [/CODE]
iam work at JSDK 1.6
the problem is not result the out put ????
the algorithm is
first fi that said :
allocate the first hole that is big enough .searching can start either at the beginning of the set holes or where the previous first fit search ended.wec can stop searching as soon as we fnd a large enough free hole.
best fit that said :
allocate the smallest hole that is big enough (the block that is the closet in size ). we must search the entire list ,unless the list is kept ordered by size
worst fit that said:
allocate the biggest hole that is big enough (the block that is the closet in size ). we must search the entire list ,unless the list is kept ordered by size
so
i wont to enter the process and saved it on to memory txt
help me
Comment