this progran will simulate a process queue, giving time slices based on the priority. The process entries will be in a file, one per line.the data is the start time, priority level, total time to run and process name.
when I run the program I got few problem
1. how can I move to the next line of the file, it seems the program keeps reading from the same line.
2. some of the data on the file either give garbge or nothing such as procname which is processname.
I suspect there is a problem with my getline.
the following is a small portion of the total program but the problem is inside the while loop.
Please I need your help, I need to turn in my homework tomorrow.
thanks a lot.
while (timing < timeU) // A loop for each time unit.
{
if (myfile.is_open())
{
cout << "time = " << timing << endl;
getline(myfile, proname);
myfile>> str_time;
if (str_time != timing)
// myfile.putback(str_time);
else //if (timing == str_time)// If the start time has arrived
{
myfile>> priority >> timerun; //data in the in the input.txt
proc.set(priority, timerun, proname); // To place in the process.
dh.insert(proc); // Insert the process.
effpro = priority + timing; // To get the effective prority.
effpro++; // to refelect the time.
cout << " inserting " << proname << endl;
}
//Read in and insert the next process.
/* if (timing == str_time)
{
nextOfproc.set(priority, timerun, proname);
dh.insert(nextOfproc);
effpro = priority + timing;
effpro++;
cout << " inserting " << proname << endl;
} */
while (!dh.IsEmpty()) // If the heap is not empty.
{
dh.deleteMin(); // To get the process from the heap.
//proc.run();
cout << " " << "running" << proname << endl; // To output the name of process.
if (!proc.done())
{
dh.insert(proc);
// heap.deleteMin();
} // If the process is not done place it in the back of the heap.
// To updating the effective priority level.
}
//timing++;
if (proc.done())
cout << proname << "finished" <<endl;
}
timing++;
}