/* * Start a read or a write request */ static void raw3215_start_io(raw3215_info *raw) { raw3215_req *req; int res; req = raw->queued_read; if (req != NULL && !(raw->flags & (RAW3215_WORKING | RAW3215_THROTTLED))) { /* dequeue request */ raw->queued_read = NULL; res = do_IO(raw->irq, req->ccws, (unsigned long) req, 0, 0); if (res != 0) { /* do_IO failed, put request back to queue */ raw->queued_read = req; } else { raw->flags |= RAW3215_WORKING; } } req = raw->queued_write; if (req != NULL && !(raw->flags & (RAW3215_WORKING | RAW3215_STOPPED))) { /* dequeue request */ raw->queued_write = NULL; res = do_IO(raw->irq, req->ccws, (unsigned long) req, 0, 0); if (res != 0) { /* do_IO failed, put request back to queue */ raw->queued_write = req; } else { raw->flags |= RAW3215_WORKING; } } }
//do the init, while something to do, do the cpu, do the io, place completed nodes in io //calculate utilazation void FCFS::start() { init(); do { do_CPU(); if (!IO->empty()) do_IO(); if (CPUnode != 0 && CPUnode->CPU_burst.back() <= 0) { CPUnode->CPU_burst.pop_back(); if (!CPUnode->CPU_burst.empty()) { CPUnode->time_on = 0; IO->insertBack(CPUnode); } else { finished->insertInorderName(CPUnode); cout << "Process: " << CPUnode->name << " finished!\n"; } CPUnode = 0; } } while (!queue->empty() || !IO->empty() || CPUnode != 0); utilization = ((double)(counter - idle) / counter) * 100; finished->calcAvg(); cout << "Total Runtime: " << counter << endl; cout << "CPU Utilization: " << utilization << endl; cout << "Average WT: " << finished->aWT << "\tAverage TT: " << finished->aTT << "\tAverage RT: " << finished->aRT << endl; }