Пример #1
0
void initialize_user_process(char **kos_argv)
{

	// zero out the memory
	bzero(main_memory, MemorySize);

	PCB *pcb = (PCB *) malloc(sizeof(PCB));
	pcb_init(pcb);
	printf("filename: %s\n", kos_argv[0]);

	if (load_user_program(kos_argv[0]) < 0) {
		fprintf(stderr,"Can't load program.\n");
		exit(1);
	}


	// set up the program counters and the stack register 

	pcb->registers[PCReg] = 0;
	pcb->registers[NextPCReg] = 4;

	/* need to back off from top of memory */
	/* 12 for argc, argv, envp */
	/* 12 for stack frame */
	pcb->registers[StackReg] = MemorySize - 24;

	dll_append(readyq, new_jval_v((void *) pcb));
	printf("Running user code.\n");

	kt_exit();
}
void init(void) {
	memcpy(__data_begin__, __rodata_end__, __data_end__ - __data_begin__);
	memset(__bss_begin__, 0, __bss_end__ - __bss_begin__);
	mach_init();
	set_trap_handler();
	tlb_init();
	pcb_init();
	main();
}
Пример #3
0
void *hw_thread_entry(void *dummy)
{
    uint16_t a, b, g;
    int fd,cnt=0,t;
    
    int lastt=0;

    iopl(3);
    ioperm(base_addr, 3, 1);

    pcb_init();
    pcb_send_cmd(PCB_POS_ANG);
    pcb_send_cmd(PCB_PNT);

    for(;;)
    {
	struct pos_ang p;
	struct timezone tz = {0, 0};
	int nr,t;
	//nr=read( uio_fd, &t, 4);
	
	while (!(inw(base_addr+2)&2));
	p.x = inw(base_addr);
	while (!(inw(base_addr+2)&2));
	p.y = inw(base_addr);
	while (!(inw(base_addr+2)&2));
	p.z = inw(base_addr);

	while (!(inw(base_addr+2)&2));
	p.a = inw(base_addr);
	while (!(inw(base_addr+2)&2));
	p.b = inw(base_addr);
	while (!(inw(base_addr+2)&2));
	p.g = inw(base_addr);

	if(!(p.x & 1))
	{
	    fprintf(stderr,"unsync!\n");
	}

	gettimeofday(&p.ts, &tz);

	pthread_mutex_lock(&pos_queue_lock);
	int rv = pos_queue_put(p);
	
	if(rv < 0)
	    die("Error - full queue!\n");

	pthread_mutex_unlock(&pos_queue_lock);

    
//	fprintf(stderr,".");
        pcb_send_cmd(PCB_PNT);
	usleep(20000);    
    }    
    return NULL;
}
Пример #4
0
kernel_main()
{
	disp_str("-------------\"kernel_main\" start-----------------\n");

	proc_id = 0;
	ticks = 0;
	k_reenter = 0;

	pcb_init(task_tty,TASK_PROC,TTY0);
	pcb_init(TestA,USER_PROC,TTY1);
	pcb_init(TestB,USER_PROC,TTY1);
	pcb_init(TestC,USER_PROC,TTY2);

	//init_clock();

	p_proc_ready = proc_table;
	proc_start();

	//stop here
	while(1){}
}