Ejemplo n.º 1
0
void main_task(void){
	int i;
	fm_time_tick begin = get_system_ticks(), end;
	while(step < SWITCH_ROUNDS){
		for(i = 0; i < TEST_TASK_NUM; ++i){
			fm_thread_resume(&thread[i]);
		}
		step++;
	}
	end = get_system_ticks();
	fm_printf("Time consume: %d\r\n", end - begin);
}
Ejemplo n.º 2
0
Archivo: idt.c Proyecto: BFridge/OS
/**
* This function handles most interrupts by finding out the interrupt #
* and calling the appropriate handler functions
*
* @param ptr_to_stack Pointer to top of stack
*/
void main_interrupt_handler(uint ptr_to_stack)
{
    struct handler_stack_frame* frame = (struct handler_stack_frame*)&ptr_to_stack;

    if (frame->interrupt_number)
    {
        klprintf(15, "Handling interrupt #%d, ticks=%d", frame->interrupt_number, get_system_ticks());

        switch(frame->interrupt_number)
        {
        
        case DIVIDE_ERROR: case DEBUG_EXCEPTION: case NMI_HARDWARE: case DEBUG_BREAKPOINT:
        case INSTRUCTION_OVERFLOW: case INSTRUCTION_OVERRANGE: case INVALID_OPCODE: case NO_COPROCESSOR:
        case DOUBLE_FAULT: case COPROCESSOR_SEG_OVERRUN: case INVALID_TSS: case SEGMENT_NOT_PRESENT:
        case STACK_FAULT: case GENERAL_PROTECTION_FAULT: case PAGE_FAULT: case RESERVED15: case COPROCESSOR_ERROR:
        case ALIGNMENT_CHECK: case MACHINE_CHECK:
            kernel_error(frame->interrupt_number, frame->stck_frame.eip, frame->stck_frame.esp,
                        frame->eax, frame->ebx, frame->ecx, frame->edx, frame->edi, frame->esi);
            break;
        case TIMER_IRQ:  
            timer_interrupt_handler();
            break;
        case SYSTEM_CALL:
            system_call( frame );
            break;
        }
    }
}
Ejemplo n.º 3
0
Archivo: timer.c Proyecto: BFridge/OS
/**
* The actual handler for a timer event generated by the 8524 interrupt
* timer
*/
void timer_interrupt_handler()
{
    ulong temp = inc_system_ticks();

    //Check sleeping tasks
    check_sleeping_tasks(temp);

    if (temp > last_do_tick)
    {
        last_do_tick = get_system_ticks();
        schedule();
    }

    //Signal the end of interrupt
    outb(0x20, 0x20);
    //Enable interrupts
    enable();
}
Ejemplo n.º 4
0
void user3(void){
	int i;
	fm_timer_handler timeout_timer = fm_timer_request(10000, time_out_set);
	fm_timer_start(timeout_timer);
	begin = get_system_ticks();
	for(i = 0; i < TEST_TIMER_NUMBER; ++i){
		timers[i] = fm_timer_request((i+1) * 100, user3_set_state);
		fm_assert(timers[i] != fm_mem_nullptr, "NULLPTR\r\n");
	}
	fm_timer_pause(timeout_timer);
	for(i = 0; i < TEST_TIMER_NUMBER; ++i){
		fm_timer_start(timers[i]);
		while(!user3_state){}
		fm_puts("User3");
		fm_timer_release(timers[i]);
		user3_state = 0;
	}
	fm_timer_resume(timeout_timer);
	fm_puts("User3 end!");
}
Ejemplo n.º 5
0
void time_out_set(void){
	fm_puts("Time out!!!");
	total = get_system_ticks() - begin;
	fm_printf("total: %d\r\n", total);
}