cout<<mm[ctr]; =========> displays the array of memory locations (box)
}
//options for memory management
gotoxy(1,15);
cout<<"OPTIONS";
gotoxy(1,17);
cout<<"1. ALLOCATION";
gotoxy(1,18);
cout<<"2. DEALLOCATION";
gotoxy(1,19);
cout<<"3. COMPACTION";
gotoxy(1,20);
cout<<"4. EXIT";
gotoxy(1,20);
cout<<"CHOICE:";
//enter choices[1-4] and place it to a variable op
gotoxy(10,22);
cin>>op; =======> Simply a menu that allows the user to choose.
//test content op
switch(op)
{
case 1:
//initialize switch to 0 which signifies that memory is not yet full.
sw=0;
//test if the memory if already full
for (ctr=0; ctr<10;ctr++)
{ res=strcmp(mm[ctr],"---");
if(res==0)
{
===> if op = 0, then sw is set to 0 to signify that the memory is not yet full (there is a vacant cell). The loop scans whether the cell is empy. If there is a cell that is empty, res=0.
//input incoming job and place in the memory
gotoxy(1,24);
cout<<"ENTER JOB NAME :";
gotoxy(18,24);
cin>>job;
==>And if res=0 (not yet full), the program accepts a job.
//here should input exclusivity
===> Program segment for exclusivity is not included. That program segment should check whether the newly entered job is unique - that is there is no previously stored job that is identical with the newly entered one.
strcpy(mm[ctr],job);
// assign 1 as switch value after allocating the incoming job
sw=1;
break;
}
==> if the job is unique, store it in the first vacant cell and sw now is equal to 1.
}
if(sw==0)
{
cout<<"MEMORY FULL!"
getch();
}
===> if sw=0, then the memory location is full. Therefore, a job cannnot be entered.
case 2: // should input deallocation
===> program segment for deallocation is not included. If I'm not mistaken, "freeing memory location" is erasing the job stored in a specific cell. That is you have to REPLACE the element with "\0" - a symbol representing white space.
//meaning:deallocation is the process of freeing a memory location.
break;
case 3: // should enter compaction
====> program segment for compaction is not included. If I am not mistaken, the program should "scan" each cell. If there is a vacant cell, the program should "move" the element of the nearest adjacent cell to that vacant cell. In this manner, all the vacant cells are at the beginning (leading) or at the end (trailing) of the array.
//compaction is the process of all occupied areas to one end or the other of the main storage.
break;