本文整理汇总了C++中Loader::loadDisk方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::loadDisk方法的具体用法?C++ Loader::loadDisk怎么用?C++ Loader::loadDisk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::loadDisk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: driver_thread
/**
* Driver Thread
* Runs the schedulers and dispatcher.
*/
void* driver_thread(void*)
{
Loader loader;
ProcessList* pList = 0;
LongTermScheduler* lts = 0;
ShortTermScheduler* sts = 0;
Dispatcher* dsp = 0;
pthread_t cpuThread;
bool done = false;
unsigned int ltsCnt = 0;
disk = new Memory(2048);
ram = new Memory(1024);
loader = Loader("data/datafile2.txt");
pList = loader.loadDisk(disk);
cpu = new Cpu(ram, pList);
lts = new LongTermScheduler(disk, ram, pList); // TODO: CPU instead of pList?
sts = new ShortTermScheduler(cpu);
dsp = new Dispatcher(cpu, ram);
if(DEBUGGING) {
cpu->setDebug(true);
lts->setDebug(true);
sts->setDebug(true);
dsp->setDebug(true);
}
// Run the schedulers once at the start
lts->schedule();
sts->rebuildQueue();
dsp->dispatch();
ltsCnt = 1;
// Spawn CPU thread.
pthread_create(&cpuThread, 0, &cpu_thread, 0);
do
{
done = true;
// Wait for interrupt.
pthread_mutex_lock(&mux);
pthread_cond_wait(&interrupt, &mux);
// LTS only runs every so often.
if(ltsCnt % 4 == 0) {
lts->schedule();
}
ltsCnt++;
// STS, Dispatcher
sts->rebuildQueue();
dsp->dispatch();
// See if we can stop.
for(unsigned int i = 0; i < pList->all.size(); i++) {
if(pList->all[i]->state != STATE_TERM_UNLOADED) {
done = false;
break;
}
}
pthread_mutex_unlock(&mux);
}
while(!done);
pthread_join(cpuThread, 0);
// Final Report
cout << "\nFinal PCB Values:\n";
cout << "=================\n";
pList->printJobs();
cout << endl;
cout << "Writing memories to disk...\n";
ram->writeDisk("ram.txt");
disk->writeDisk("disk.txt");
return 0;
}