Beispiel #1
0
int main() 
{
   	int pid;

	InitKernelData();	//call InitKernelData()  to set kernel data
	InitKernelControl();	//call InitKernelControl() (see below)	
	
	pid = DeQ(&free_q);	
	StartProcISR((int) pid, (int) IdleProc);
	
	//phase 3
	pid = DeQ(&free_q);	
	StartProcISR((int) pid, (int) InitProc);

	//phase 7
	pid = DeQ(&free_q);	
	StartProcISR((int) pid, (int) FileService);

	//phase 6
	pid = DeQ(&free_q);	
	StartProcISR((int) pid, (int) ShellProc);

	pid = DeQ(&free_q);
	StartProcISR((int) pid, (int) StdinProc);

	pid = DeQ(&free_q);
	StartProcISR((int) pid, (int) StdoutProc);
	
	LoadRun(pcb[0].TF_ptr);	//call LoadRun() to load/run IdleProc	
	return 0;		//this will never be executed

}
Beispiel #2
0
int main() {
   int pid;
   
   InitKernelData();
   InitKernelControl();
   pid = DeQ(&free_q);
   StartProcISR(pid,(unsigned int)IdleProc);
   pid = DeQ(&free_q);
   StartProcISR(pid,(unsigned int)InitProc);
   LoadRun(pcb[0].TF_ptr);
   
   return 0;   // not reached, but compiler needs it for syntax
}
Beispiel #3
0
int main() 
{
   	int pid;

	InitKernelData();	//call InitKernelData()  to set kernel data
	InitKernelControl();	//call InitKernelControl() (see below)	
	
	pid = DeQ(&free_q);	
	StartProcISR(pid);
	LoadRun(pcb[0].TF_ptr);	//call LoadRun() to load/run IdleProc
	
	return 0;		//this will never be executed
}
Beispiel #4
0
void KernelMain(TF_t *TF_ptr) {
   
  
   int new_pid;
   
	pcb[running_pid].TF_ptr = TF_ptr;
	switch(TF_ptr ->intr_id) {
	    case(TIMER_INTR):
	       TimerISR();
		OS_clock++;
		checkWait();
		outportb(0x20, 0x60); //stops the timer pic with a code
	       break;
		case(SLEEP_INTR):
		   Sleep_ISR(TF_ptr->eax);
		   break;
		case(GETPID_INTR):
		   TF_ptr->eax = running_pid;
		   break;
		case(STARTPROC_INTR):
		   new_pid = DeQ(&free_q);
		   StartProcISR(new_pid,TF_ptr->eax);
		   break;
		case(SEMWAIT_INTR):
		   SemWaitISR(TF_ptr->eax);
	           break;
		case(SEMPOST_INTR):
		   SemPostISR(TF_ptr->eax);
		   break; 
		case(SEMGET_INTR):
		   SemGetISR(TF_ptr->eax);
	  	   break;
		case(MSGSND_INTR):
		    MsgSndISR(TF_ptr->eax);
		    break;
		case(MSGRCV_INTR):
		    MsgRcvISR(TF_ptr->eax); 
		    break;
	    default:
		cons_printf("Panic: unknown intr ID (%d)!\n",TF_ptr->intr_id);
		breakpoint();
	}		
   
   Scheduler();  
   LoadRun(pcb[running_pid].TF_ptr); 
}
Beispiel #5
0
void KernelMain(TF_t *TF_ptr) 
{
	int new_pid, i, pid, len;
	char key;

	pcb[running_pid].TF_ptr = TF_ptr;	//save TF_ptr to PCB of running process
	
	switch(TF_ptr->intr_id)			//switch on TF_ptr->intr_id
	{
		case TIMER_INTR:
				TimerISR();	//call TimerISR()
				outportb(0x20, 0x60);	//dismiss timer event: send PIC with a code
				OS_clock++;
				len = sleep_q.len;

				for(i = 0; i < len; i++)
				{
					pid = DeQ(&sleep_q);
					if(OS_clock == pcb[pid].wake_time)
					{
						EnQ(pid, &ready_q);
						pcb[pid].state = READY;
					}
					else
					{
						EnQ(pid, &sleep_q);
					}	
				}
				break;
		case GETPID_INTR:
				GetPidISR();
				break;
		case SLEEP_INTR:
				SleepISR();
				break;
		default:
				cons_printf("Panic: unknown intr ID (%d)!\n", TF_ptr->intr_id);
				breakpoint();		//fallback to GDB
	}

	//same as simulated, handle keystroke simulated events (s/e/b/x, but no 't' key)
	if(cons_kbhit())
	{
		key = cons_getchar();
		switch(key)
		{
			case 's':
				new_pid = DeQ(&free_q);	//dequeue free_q for a new pid
				if (new_pid == -1)	//if the new pid (is -1) indicates no ID left
				{				
					cons_printf("Panic: no more available process ID left!\n");	//show msg on target PC			
				}
				else
				{
					StartProcISR(new_pid);	//call StartProcISR(new pid) to create new proc
				}
				break;
			case 'e':
				EndProcISR();	//call EndProcISR() to handle this event
				break;
			case 'b':
				breakpoint();	//call breakpoint(); to go into GDB
				break;
			case 'x':
				exit(0);	//just call exit(0) to quit MyOS.dli
				break;
			default :		// no keys were pressed
				break;
		}
	}
	Scheduler();				//call scheduler() to process to load/run if needed
	LoadRun(pcb[running_pid].TF_ptr);	//call LoadRun(pcb[running_pid].TF_ptr) to load/run selected proc
}
Beispiel #6
0
void KernelMain(TF_t *TF_ptr) 
{
	int new_pid, i, pid, len;	

	pcb[running_pid].TF_ptr = TF_ptr;	//save TF_ptr to PCB of running process
	
	switch(TF_ptr->intr_id)			//switch on TF_ptr->intr_id
	{
		case TIMER_INTR:
				TimerISR();	//call TimerISR()
				outportb(0x20, 0x60);	//dismiss timer event: send PIC with a code
				OS_clock++;
				len = sleep_q.len;

				for(i = 0; i < len; i++)
				{
					pid = DeQ(&sleep_q);
					if(OS_clock == pcb[pid].wake_time)
					{
						EnQ(pid, &ready_q);
						pcb[pid].state = READY;
					}
					else
					{
						EnQ(pid, &sleep_q);
					}	
				}
				break;
		case GETPID_INTR:
				GetPidISR();
				break;
		case SLEEP_INTR:
				SleepISR();
				break;
		//phase 3 new switch() cases		
		case STARTPROC_INTR:
				new_pid = DeQ(&free_q);	//dequeue free_q for a new pid
				if (new_pid == -1)	//indicates no ID left
				{				
					cons_printf("Panic: no more available process ID left!\n");	//show msg on target PC			
				}
				else
				{
					StartProcISR(new_pid, TF_ptr->eax);//create new proc
				}
				break;
		case SEMGET_INTR:
				SemGetISR(TF_ptr->eax);
				break;
		case SEMWAIT_INTR:
				SemWaitISR(TF_ptr->eax);
				break;
		case SEMPOST_INTR:
				SemPostISR(TF_ptr->eax);
				break;
		//phase 4
		case MSGSND_INTR:
				MsgSndISR(TF_ptr->eax);	//Check if parameter needed*********
				break;
		case MSGRCV_INTR:
				MsgRcvISR(TF_ptr->eax);
				break;
		default:
				cons_printf("Panic: unknown intr ID (%d)!\n", TF_ptr->intr_id);
				breakpoint();		//fallback to GDB
	}

	Scheduler();				//call scheduler() to process to load/run if needed
	LoadRun(pcb[running_pid].TF_ptr);	//call LoadRun(pcb[running_pid].TF_ptr) to load/run selected proc
}