int main(int argc,char **argv) { pthread_t zputhread; pthread_attr_t zputhreadattr; void *ret; if (argc<2) { return help(); } poll_init(); gui_init(); zpuino_interface_init(); if (load_device_map("device.map")<0) { fprintf(stderr,"SIMULATOR: Error loading device map\n"); return -1; } int infile = open(argv[1],O_RDONLY); read(infile,_memory,32768); close(infile); zpuino_io_post_init(); gui_post_init(); // Spawn terminal /* int pid; switch(pid=vfork()) { case 0: return execl("./terminal/terminal","terminal",uart_get_slave_name(),NULL); default: break; } */ /* if (setup_programmer_port()<0) return -1; */ signal(SIGINT,&sign); _usp=get_initial_stack_location(); zpuino_clock_start(); // start processing thread pthread_attr_init(&zputhreadattr); pthread_create(&zputhread,&zputhreadattr, zpu_thread, NULL); zpu_halt(); poll_loop(); pthread_join(zputhread,&ret); return 0; }
static int loop(void){ /* * Read a string from stdin, and then send it ten times to * the client queues. */ int status; char buf[DBQ_RECLEN]; int i; /* * Process new connections, hangups, etc. */ status = poll_loop(gct); if(status != 0) fprintf(stdout, "Status from poll loop: %d\n", status); memset(buf, '\0', DBQ_RECLEN); while(fgets(buf, DBQ_RECLEN, stdin) != NULL){ /* * Process new connections, hangups, etc. */ status = poll_loop_nowait_nonblock(gct); if(status != 0) fprintf(stdout, "Status from poll loop: %d\n", status); if(strncmp(buf, "quit", 4) == 0){ set_quit_flag(); break; } for(i = 1; i <= 4; ++i){ write_client_queues(buf, DBQ_RECLEN); } join_finished_threads(); spawn_client_threads(); } return(0); }