本文整理汇总了C++中Program::assign_pid方法的典型用法代码示例。如果您正苦于以下问题:C++ Program::assign_pid方法的具体用法?C++ Program::assign_pid怎么用?C++ Program::assign_pid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program::assign_pid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeScheduling
void Simulator::executeScheduling()
{
int counter = 0;
// Create a ready queue
display( "OS: preparing all processes" );
Queue* readyQueue = new Queue();
for( Program program : programs_ )
{
program.prepare();
readyQueue->push( program );
}
// Execute the programs according to RR scheduling
while( !readyQueue->empty() || !suspendedPrograms_.empty() )
{
// Process interrupts
while( !interrupts_.empty() )
{
int interrupt = interrupts_.front();
interrupts_.pop();
if( interrupt != 0 )
{
Program suspendedProgram = suspendedPrograms_.at( interrupt );
suspendedPrograms_.erase( interrupt );
suspendedProgram.prepare();
readyQueue->push( suspendedProgram );
}
}
// Execute programs in ready queue
if( !readyQueue->empty() )
{
display( "OS: selecting next process" );
Program program = next(readyQueue);
if( program.process_control_block().processID == 0)
{
program.assign_pid(++counter);
}
// Execute the program until it is interupted
executeProgram(&program);
if( program.process_control_block().state == RUNNING )
{
program.prepare();
readyQueue->push(program);
}
}
else
{
display("OS Idle: Waiting for I/O to complete");
wait(30); // 30 millisecond idle before checking again
}
}
}