uint32_t write_pty_master(fs_node_t * node, uint32_t offset, uint32_t size, uint8_t *buffer) { pty_t * pty = (pty_t *)node->device; size_t l = 0; for (uint8_t * c = buffer; l < size; ++c, ++l) { input_process(pty, *c); } return l; }
int main(int argc, char* argv[]) { int i,j = 0; unsigned int frame = 0; char *rom_file = NULL; int rom_size = 0; double z80_cycles = 0; if (argc < 2) { fprintf(stderr, "Usage: %s ROM_FILE\n", argv[0]); return 1; } rom_file = argv[1]; memory_init(); rom_size = memory_load(rom_file); if (rom_size < 0) { fprintf(stderr, "Couldn't read ROM file %s\n", rom_file); return 1; } printf("Read ROM %s (%d bytes)\n", rom_file, rom_size); io_init(); video_init(); input_init(); vpu_init(); Z80Reset(&z80_state); z80_state.pc = 0; while (input_quit() == 0) { z80_cycles += Z80Emulate(&z80_state, Z80_CYCLES_PER_STEP); vpu_draw_screen(); video_flip(); video_wait_frame(); input_process(); Z80NonMaskableInterrupt (&z80_state); frame++; } printf("Ran %d frames and %f Z80 cycles.\n", frame, z80_cycles); return 0; }
int main(int argc, char *argv[]){ pid_t pid; // initialize shared memory for IPCs shared_memory(); pid = fork(); switch(pid){ case -1: // process creation failed die("process creation failed"); case 0: // input process pid = fork(); switch(pid){ case -1: // process creation failed die("process creation failed"); case 0: // event key process (input) return eventkey_process(); default: // input process return input_process(); } default: pid = fork(); switch(pid){ case -1: // process creation failed die("process creation failed"); case 0: // output process return output_process(); default: // main process main_process(); } } free_shared(); return 0; }
main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "F:ntvcdr:i")) != EOF) switch (c) { case 'F': if (!optarg || optarg[1]) usage(argv[0]); field_sep = *optarg; break; case 'r': if (!optarg) usage(argv[0]); remote = strdup(optarg); break; case 'n': o_print_name = 0; break; case 't': o_print_type = 0; break; case 'v': o_print_value = 0; break; case 'c': o_verify = 1; break; case 'd': o_print_decimal = 1; break; case 'i': o_ignore_error = 1; break; case '?': usage(argv[0]); } if (argv[optind] != NULL) { LONG ret; if (argv[optind + 1] != NULL) usage(argv[0]); /* Dump a key */ print_registry(split_name(argv[optind], &rootkey, rootname)); if (remote && (ret = RegCloseKey(rootkey)) != ERROR_SUCCESS) wperror("RegCloseKey", ret); } else /* Read input and add keys */ input_process(); return (0); }
int main(int argc, char **argv) { int ixs=832, iys=624; int player_number = 1; scene *current_scene = NULL; srand(time(NULL)); if(argc == 2 && (!strcmp(argv[1], "--fullscreen"))) { fullscreen_mode = 1; ixs = 1024; iys = 768; } if(!init_renderer(ixs, iys)) { fprintf(stderr, "Renderer failed to initialize!\n"); exit(1); } init_scenes(); while(!user_quit) { current_scene = get_current_scene(); if(!render_scene(current_scene, player_number)) { fprintf(stderr, "Render of scene failed!\n"); exit(1); } if(!input_process(current_scene, player_number)) { fprintf(stderr, "Input processing failed!\n"); exit(1); } } exit(0); return 0; }
int main(int argc, char *argv[]) { char input_file[ONE_LINE], *func = {" main(int argc, char *argv[]) : "}; FILE *file_ptr; SHELL model; TID wallTime, cpuTime; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD,&NumProcs); MPI_Comm_rank(MPI_COMM_WORLD, &Rank); time_step(10,1); // time controll for total shell model calc // Read file names and open file containing basic input data if(argc >= 2) { // as program parameters strcpy(input_file, argv[1]); // save in_data input_file } else { // or as separate typed in filename printf("\n Type in file name for basic shell model data = "); scanf("%s",input_file); } // end of data-file-name input // Time control for the total shell model calculation wallClock(1,0); // initialization cpuClock(1,0); wallClock(1,1); // start time cpuClock(1,0); input_process(input_file, &model); // module shell-model-input.c /******************** test output ********/ if(Rank == MASTER) { FILE *file_ptr; if((file_ptr = fopen(model.title,"a"))== NULL) { printf("\n\nRank(%d): Error in function main()():",Rank); printf("\nWrong file = %s for the output data\n", model.title); MPI_Abort(MPI_COMM_WORLD,Rank); } fprintf(file_ptr,"\n\n NumProcs = %d\n\n\n",NumProcs); fflush(file_ptr); fclose(file_ptr); } // end MASTER /**************** end test outpt ********/ strcpy(TEST_FILE_NAME, model.title); // parameter for test output // all files identifies with rank number if( (!strcmp(model.type_calc,"random-start")) ||(!strcmp(model.type_calc,"dimension"))) { /* ** A Lanczos iteration shell model calculation ** based on random initial state. */ id_LancIterateCalc(&model); } else { printf("\n\n The calculation process: %s not implemented\n\n", model.type_calc); MPI_Abort(MPI_COMM_WORLD,Rank); } // Stop and read total process time wallClock(1,2); // stop tile cpuClock(1,2); wallTime = wallClock(1,3); // read time cpuTime = cpuClock(1,3); if(Rank == MASTER) { if((file_ptr = fopen(model.title,"a"))== NULL) { printf("\n\nError in function lanc-main.c():"); printf("\nWrong file = %s for the output data\n", model.title); MPI_Abort(MPI_COMM_WORLD,Rank); } fprintf(file_ptr, "\n\nTotal shell model process wall time used"); fprintf(file_ptr, " %llu hour %llu min %llu sec", wallTime.hour, wallTime.min, wallTime.sec); fprintf(file_ptr, "\nTotal shell model process cpu time used"); fprintf(file_ptr, " %llu hour %llu min %llu sec\n", cpuTime.hour, cpuTime.min, cpuTime.sec); fclose(file_ptr); } // end MASTER // MPI_Finalize(); MPI_Finalize(); return 0; // sucsessfull termination } // End: function main()
/* * Main function that will create all the process for processing the input */ int main() { // pipes that used to pass the data int input_pipe[2]; int carriage_handler_pipe[2]; int asterisk_handler_pipe[2]; // Children pid pid_t carriage_process_pid; pid_t asterisks_process_pid; pid_t output_pid; // create pipes to connect processes if (pipe(input_pipe) == -1) { perror("creating input pipe"); exit(1); } if (pipe(carriage_handler_pipe) == -1) { perror("creating newline handler pipe"); exit(1); } if (pipe(asterisk_handler_pipe) == -1) { perror("creating asterisk handler pipe"); exit(1); } // fork the chile processes if ((carriage_process_pid = fork()) == -1) { perror("fork carriage processing"); exit(1); } if (carriage_process_pid != 0) { // parent process close(input_pipe[READ]); input_process(input_pipe[WRITE]); wait(&carriage_process_pid); } else { // chile process if ((asterisks_process_pid = fork()) == -1) { perror("fork asterisks processing"); exit(1); } if (asterisks_process_pid != 0) { // parent process close(input_pipe[WRITE]); close(carriage_handler_pipe[READ]); carriage_processing_process(input_pipe[READ], carriage_handler_pipe[WRITE]); wait(&asterisks_process_pid); } else { // child process if ((output_pid = fork()) == -1) { perror("fork output"); exit(1); } if (output_pid != 0) { // parent process close(carriage_handler_pipe[WRITE]); close(asterisk_handler_pipe[READ]); asterisks_processing_process(carriage_handler_pipe[READ], asterisk_handler_pipe[WRITE]); wait(&output_pid); } else { // child process close(asterisk_handler_pipe[WRITE]); output_process(asterisk_handler_pipe[READ]); } } } return 0; }