MadhavBahl / OperatingSystem-Algorithms

A GUIDE TO ALGORITHMS RELATED TO OPERATING SYSTEMS.
https://madhavbahlmd.github.io/OperatingSystem-Algorithms/
MIT License
25 stars 13 forks source link

The code doesn't show exact output #5

Open ghost opened 4 years ago

ghost commented 4 years ago

when the process once got allocated,it again searches to another block of size greater. The modification should be done as given below: The flag should be used which checks for the process which is already allocated into the block. int flag1[n]; for(i=0;i<n;i++) { flag1[i]=0; } for(i=0;i<n;i++){ for(j=0;j<nb;j++) { if(blockSize[j]>=jobSize[i] && blockSize[j]>0 && flag1[i]==0) { alloc[i]=j; flag1[i]=1;

            blockSize[j]=blockSize[j]-jobSize[i];

        }
    }

}