Beispiel #1
0
// Print a complete description of the 
// process referenced in each element (node)
// of the queue.
// The complete description includes id, service time,
// interarrival time, arrival time, time at which
// service begins, and time at which service is completed.
void printProcessesInQueue( QueuePointer qp ) {
  NodePointer np = qp->pointerToHead;
  while( np != NULL ) {
    printProcess( np->processPointer );
    np = np->pointerToPrevNode;
  } // while
} // printProcessInQueue( QueuePointer )
Beispiel #2
0
// print the contents of the array that
// holds the elements of the priority queue
// (this function is to help in debugging)
void printPriorityQueue( PriorityQueuePointer pq ) {
  int i;
  for( i = 1; i <= pq->size; i++ ) {
    printf( "%4d ", i );
    printProcess(pq->data[i]);
    printf( "\n" );
  } // for
  printf( "\n" );
} // printPriorityQueue( PriorityQueuePointer )
Beispiel #3
0
/*
 * Launch the kernel, i.e. launch first process in the running list
 */
void startKernel(void)
{
	LOG("Gonna start the kernel, remind all processes :\n");
	
	int i = 0;
	int max = runningList.size;
	for( ; i < max ; i++)
	{
		struct processDescriptor* p = 
			(struct processDescriptor*) getIndex(&runningList, i)->element;
		printProcess(p);
	}
	struct processDescriptor* process = 
		(struct processDescriptor*) getIndex(&runningList, 0)->element;
	LOG("Starting process : ");
	LOG_INT(process->pid);
	LOG_CONT("\n");
/*	LOG_INT(process->ppid); */
	printProcess(process);
	LOG_CONT("\n");
	startProcess(&(process->processState));
}
Beispiel #4
0
void 
viewProcessDump(void){

	int pid;

	int i,
		niceval[4] = {19, 10, 0, -12};

	for(i = 0; i < 4; i++){
		if((pid = fork()) < 0){// Error
			printf(1, "Error forking!\n");
		}
		else if(pid == 0){ //Child
		  	nice(niceval[i]);
		  	printf(2, "-----Before Child %d-----\n", niceval[i]);
		  	printProcess();

		  	int j;
	 		for(j=0; j < 50; j++)
	 			;

	 		printf(2, "-----After Child %d------\n", niceval[i]);
		  	printProcess();

	 		exit();
	}

}


		while(wait() >= 0)
			;


		printf(2, "\n\n");

}
Beispiel #5
0
/* create new process and returns the cell containing the process */
struct cell * createProcess(void (*f)(void), void* baseAddress)
{
	void* area = get2M();
	LOG("Creating process at base address : ");
	LOG_INT((int)area);
	LOG_CONT("\n");
	/* Prepare initial processState*/
	struct processDescriptor * process =
		kalloc(sizeof(struct processDescriptor));
	
	process->processState.pc = f;
	process->processState.sp =  area + 2*SPACE - 4;
	/* When exiting, auto-delete process */
	process->processState.lr = &deleteProcess; 
	process->ppid = choosePPID();
	pidCounter++;
	process->pid = pidCounter;
	process->map.baseAddress = area;
	process->baseAddress = baseAddress;
	printProcess(process);
	insertAtEnd(&stoppedList, process);
	return getIndex(&stoppedList, 0)->previous;
}