Ejemplo n.º 1
0
void IOScheduler(){
	if(param_ptr->device_id==TERMINAL||param_ptr->device_id==COM_PORT){
		IOD *Descriptor = sys_alloc_mem(sizeof(IOD));
		Descriptor->ppt = COP;
		strcpy(Descriptor->PCBName,COP->processName);
		Descriptor->buffer = param_ptr->buf_addr;
		Descriptor->count = param_ptr->count_addr;
		Descriptor->requestType = param_ptr->op_code;
		if(param_ptr->device_id==TERMINAL){
			if(TerminalQueue-> count == 0){
				TerminalQueue->head = Descriptor;
				TerminalQueue->tail = Descriptor;
				TerminalQueue->count = 1;
				ProcessIORequest(1);
			}else{
				TerminalQueue->tail->next = Descriptor;
				TerminalQueue->tail = TerminalQueue->tail->next;
				TerminalQueue->count++;
			}
		}else if(param_ptr->device_id==COM_PORT){
			if(Com_PortQueue-> count == 0){
				Com_PortQueue->head = Descriptor;
				Com_PortQueue->tail = Descriptor;
				Com_PortQueue->count = 1;
				ProcessIORequest(2);
			}else{
				Com_PortQueue->tail->next = Descriptor;
				Com_PortQueue->tail = Com_PortQueue->tail->next;
				Com_PortQueue->count++;
			}
		}
		COP->state = 0;
		insertPCB(COP);
		//blockPCB(COP->processName);
	}
}
Ejemplo n.º 2
0
void HALdisplayDriver ()
{
    do
    {
        BlockSignals ();
        if (messageFromHALos)
        {
            messageFromHALos = 0;
            GetMessageFromHALos ();
            ProcessIORequest ();
            SendMessageToHALos ();
        }
        UnblockSignals ();
    } while (1);

    return;
}
Ejemplo n.º 3
0
void interrupt sys_call(void){

	static IOD *temp;
	
	//Saves the ss and sp register to a temp storage
	ss_save2 = _SS;
	sp_save2 = _SP;
	COP->stack = (unsigned char *)MK_FP(ss_save2,sp_save2);
	//Updates the stacktop for context switch
	
	
	//Access Parameters that sys_req placed on the stack
	param_ptr = (params*)(COP->stack+sizeof(context));
	
	//Switching to a temp stack
	new_ss = FP_SEG(sys_stack);
	new_sp = FP_OFF(sys_stack)+ SYS_STACK_SIZE;
	_SS = new_ss;
	_SP = new_sp;
	
	trm_getc();
	
	if(TerminalQueue->event_flag==1 && TerminalQueue->count > 0){
		TerminalQueue->event_flag = 0;
		temp = TerminalQueue->head;
		TerminalQueue->head = TerminalQueue->head->next;
		unblockPCB(temp->ppt->processName);
		sys_free_mem(temp);
		TerminalQueue->count--;
		if(TerminalQueue->count!=0){
			ProcessIORequest(1);
		}
	}
	if(Com_PortQueue->event_flag==1 && Com_PortQueue->count > 0){
		Com_PortQueue->event_flag = 0;
		temp = Com_PortQueue->head;
		Com_PortQueue->head = Com_PortQueue->head->next;
		unblockPCB(temp->ppt->processName);
		sys_free_mem(temp);
		Com_PortQueue->count--;
		if(Com_PortQueue->count!=0){
			ProcessIORequest(1);
		}
	}
	
	//Process is idle
	if (param_ptr -> op_code == IDLE){
		//Sets state to running and adds it back into the readyQueue
		COP -> state = 2; 
		PriorityEnqueue(readyQueue,COP);
	}
	//Process is completed and ready for deletion 
	if (param_ptr -> op_code == EXIT){
		//Frees the memory of the PCB and sets the PCB to NULL
		freePCB(COP);
		COP = NULL;
	}
	if (param_ptr -> op_code == READ ||param_ptr -> op_code == WRITE ||param_ptr -> op_code == CLEAR ||param_ptr -> op_code == GOTOXY ){
		IOScheduler();
	}
	//Dispatches the next process in the readyQueue
	dispatch();
}