rendered paste bodyint ioComplete(int device)
{
/*** INSERT YOUR CODE HERE ***/
int pid;
if(iowaitList[device].count > 0)
{
pid = serveList(&iowaitList[device]);
insertList(&readyList, pid, priorityFunctionPtr);
pcb[pid].state = state_ready;
fprintf(stdout, "%d: process %d I/O complete on device %d\n", now, pid, device);
if(running == -1)
{
dispatching();
}
else if(preemptive &&compare_burstlength(pid,running))
{
insertList(&readyList,running,priorityFunctionPtr);
fprintf(stdout, "%d: process %d pre-empted\n", now, running);
running = -1;
dispatching();
}
}
return 1;
}