src/NextFit.cpp
void NextFit::addProcP(char p, int n) {

	//Find the next place the process can be placed
    int index = m.findNextFit(lastUsed, n).first;

	//If de-fragmentation is required, do so
	if (index == -1) {

		//Note that defragmentation has begin
		std::cout << t << "Cannot place process " << p << " -- starting defragmentation\n";

		//DeFrag
		m.deFrag();
        lastUsed = 0;

        //Find where to place the process now
        index = m.findNextFit(lastUsed, n).first;
	}

    //Note that the process was placed
    std::cout << t << "Placed process " << p << ":\n";
    
	//Place the process and note where
	m.allocateMemory(index, n ,p);
    lastUsed = (index + n) % m.size();
}
//Give process p n memory units
Give process p n memory units
Give process p n memory units
void NextFit::addProcP(char p, int n) {
    int index = m.findNextFit(lastUsed, n).first;
	if (index == -1) {
		std::cout << t << "Cannot place process " << p << " -- starting defragmentation\n";
		m.deFrag();
        lastUsed = 0;
        index = m.findNextFit(lastUsed, n).first;
	}
    std::cout << t << "Placed process " << p << ":\n";
	m.allocateMemory(index, n ,p);
    lastUsed = (index + n) % m.size();
}
void NextFit :: addProcP ( char p , int n ) { int index = m . findNextFit ( lastUsed , n ) . first ; if ( index == -1 ) { std :: cout << t << " " << p << " \n " ; m . deFrag ( ) ; lastUsed = 0 ; index = m . findNextFit ( lastUsed , n ) . first ; } std :: cout << t << " " << p << " \n " ; m . allocateMemory ( index , n , p ) ; lastUsed = ( index + n ) % m . size ( ) ; }
Give process p n memory units
Give process p n memory units
//Find the next place the process can be placed //If de-fragmentation is required, do so //Note that defragmentation has begin //DeFrag //Find where to place the process now //Note that the process was placed //Place the process and note where