本文整理汇总了C++中Disk::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Disk::readLine方法的具体用法?C++ Disk::readLine怎么用?C++ Disk::readLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Disk
的用法示例。
在下文中一共展示了Disk::readLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveToRAM
void LongScheduler::moveToRAM()
{
ofstream longSchedLog_RAM;
longSchedLog_RAM.open("longSchedLog-RAM.txt", fstream::out);
int j = current_process;
// write the processes into RAM
for(j; j<=30; j++)//should loop 30 times for the number of totalt processes
{
longSchedLog_RAM << "PID: " << j << endl;
longSchedLog_RAM << "Free Space in RAM: " << ram.howManyFreeBytes() << endl;
if(((pcb_table.getCodeSize(j) + 44)*8 ) < ram.howManyFreeBytes())//check to make sure that there is enough room to write the whole process to RAM
{
longSchedLog_RAM << "Process size: " << ((pcb_table.getCodeSize(j)+44)*8) << endl;
for(int k = 0; k <= (pcb_table.getCodeSize(j)+44); k++)//loop to write the entire process to RAM
{
ram.writeNBytesToNextFreeAdr(disk1.readLine(k).c_str(),8);//writing process to RAM
}
longSchedLog_RAM << "Successfully transferred process " << j << " into RAM" << endl;
longSchedLog_RAM << "Amount of space left in RAM: " << ram.howManyFreeBytes() << endl;
//move pid for process that was just written to RAM from the new queue to the running queue
running_queue.push(new_queue.front());
pcb_table.setStatus(j,RUNNING);//to update the status of the process in the PCB
longSchedLog_RAM << "Successfully added process to running queue" << endl;
//remove pid for process that was just written to RAM from new queue
new_queue.pop();
longSchedLog_RAM << "Successfully removed process from new queue" << endl << endl;
}
else
{
current_process = j;// this will be so that the next time the moveToRAM functon is called, it will know where to start so
// not to duplicate the processes
return;
}
}
longSchedLog_RAM.close();//close ostream
}