All pastes #168304 Raw Edit

RAWR

public text v1 · immutable
·published 2006-09-12 21:37 UTC
rendered paste body
int createProcess(int priority)
{
  int pid;
   
   /*** INSERT YOUR CODE HERE ***/
	
	pid = nextpid;

	nextpid++;
	
	insertList(&readyList,pid,priorityFunctionPtr);
	
	pcb[pid].priority = priority;
	pcb[pid].state = state_new;
	
	fprintf(stdout, "%d: process %d created\n", now, pid);
	
	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 pid;
}