当前位置: 首页>>代码示例>>C++>>正文


C++ Disk::readLine方法代码示例

本文整理汇总了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
}
开发者ID:wpegg-dev,项目名称:College-Work,代码行数:49,代码来源:long-term_scheduler.cpp


注:本文中的Disk::readLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。