int main(int argc, char **argv) { int ins_pid; init_arguments (&argc, &argv); //打开锁文件 lockfile = open (LOCKFILE, O_RDWR | O_CREAT , LOCKMODE); if (lockfile < 0){ perror ("Lockfile"); exit(EXIT_FAILURE); } if ( (ins_pid = program_running_check ()) ) { fprintf(stderr,"@@ERROR: zRuijie Already " "Running with PID %d\n", ins_pid); exit(EXIT_SUCCESS); } init_info(); init_device(); init_frames (); signal (SIGINT, signal_interrupted); signal (SIGTERM, signal_interrupted); signal (SIGALRM, signal_alarm); show_local_info(); send_eap_packet (EAPOL_START); alarm(5); pcap_loop (handle, -1, get_packet, NULL); /* main loop */ pcap_close (handle); return 0; }
/* Initializes paging for the system address space */ void init_mm() { init_table_pages(); init_frames(); init_dir_pages(); set_cr3(get_DIR(&task[0].task)); set_pe_flag(); }
/* Initializes paging for the system address space */ void init_mm() { init_table_pages(); init_frames(); init_dir_pages(); init_heap_structs(); allocate_DIR(&task[0].task); set_cr3(get_DIR(&task[0].task)); set_pe_flag(); }
void A2::init_linkedlists() { init_frames(); for(int i = 0; i < frame_size; i++) { if(i != (frame_size - 1)) { frames[i].next = &frames[i+1]; // Establishing pointers to next frame. } else { frames[i].next = &frames[0]; // Point to the beginning of the list. } } }
/* Initializes paging for the system address space */ void init_mm() { int i; init_table_pages(); init_frames(); init_dir_pages(); for (i = 0; i < NR_TASKS; ++i){ vdir[i] = 0; } allocate_DIR(&task[0].task); set_cr3(get_DIR(&task[0].task)); set_pe_flag(); }
GtkWidget *konepuremilitary_dcu_dialog_new(GtkWindow *parent, RoccatDevice *device) { KonepuremilitaryDcuDialog *dcu_dialog; KonepuremilitaryDcuDialogPrivate *priv; dcu_dialog = KONEPUREMILITARY_DCU_DIALOG(g_object_new(KONEPUREMILITARY_DCU_DIALOG_TYPE, "transient-for", parent, NULL)); priv = dcu_dialog->priv; priv->device = device; init_frames(dcu_dialog); return GTK_WIDGET(dcu_dialog); }
GtkWidget *nyth_tcu_dcu_dialog_new(GtkWindow *parent, RoccatDevice *device) { NythSensorDcuDialog *tcu_dcu_dialog; NythSensorDcuDialogPrivate *priv; tcu_dcu_dialog = NYTH_TCU_DCU_DIALOG(g_object_new(NYTH_TCU_DCU_DIALOG_TYPE, "transient-for", parent, NULL)); priv = tcu_dcu_dialog->priv; priv->device = device; init_frames(tcu_dcu_dialog); return GTK_WIDGET(tcu_dcu_dialog); }
DWORD WINAPI eap_thread() { extern pcap_t *handle; extern char devname[]; init_device(); init_frames (); send_eap_packet (EAPOL_START); pcap_loop (handle, -1, get_packet, NULL); /* main loop */ pcap_close (handle); memset (devname, 0, MAX_DEV_NAME_LEN); update_interface_state(NULL); return 0; }
GtkWidget *koneplus_tcu_dcu_dialog_new(GtkWindow *parent, RoccatDevice *device) { KoneplusSensorDcuDialog *tcu_dcu_dialog; KoneplusSensorDcuDialogPrivate *priv; tcu_dcu_dialog = KONEPLUS_TCU_DCU_DIALOG(g_object_new(KONEPLUS_TCU_DCU_DIALOG_TYPE, "transient-for", parent, NULL)); priv = tcu_dcu_dialog->priv; priv->device = device; init_frames(tcu_dcu_dialog); return GTK_WIDGET(tcu_dcu_dialog); }
void A2::lru() { faults = 0; init_frames(); cout << "Running Least Recent Used Algorithm--" << endl; for(unsigned int i = 0; i < v_pages.size(); i++) { int m = search(v_pages[i].p_number); if(m != -1) { Page tmp = frames.at(m); sort(m+1); // Bubble sort, moves the element to the front of the list if found. frames.at(0) = tmp; } else { sort(frame_size); frames.at(0) = v_pages[i]; faults++; } } cout << "Faults: " << faults << endl; }
int main(int args,char **argv) { char cho; debug_mode = 0; if(args&&strcmp(*argv,"-d")==0) debug_mode = 1; if(init_device()!=DONE) { perror("device initialized failed\n"); return ERROR; } if(init_frames()!=DONE) { perror("frame initialized failed\n"); return ERROR; } signal (SIGINT, onExit); signal (SIGTERM, onExit); while(logon()!=DONE) { printf("logon failed retry?(Y?)\n"); //getchar(); //scanf("%c",&cho); cho='Y'; if(cho!='Y'&&cho!='y') { printf("Oh my God , Game Over!~\nehhhhh~~~~T^T~\n"); logoff(); return DONE; } } printf("Bye Bye Honey~(*^_^*)\n"); return DONE; }
/* Algorithms */ void A2::opt() { faults = 0; init_frames(); int index = 0; int max = 0; cout << "Running Optimal Algorithm--" << endl; for(unsigned int i = 0; i < v_pages.size(); i++) { int m = search(v_pages[i].p_number); if(m == -1) { for(int n = 0; n < frame_size; n++) { int disp = calculate_disp(i, frames[n].p_number); if(max < disp) { max = disp; // Looking for highest displacement for page replacement. index = n; // Position of the highest displacement. } } frames[index] = v_pages[i]; max = 0; faults++; } } cout << "Faults: " << faults << endl; }
int main(int argc, char **argv) { AVFormatContext *afc; AVStream *st; AVPacket pk; struct frame_format frame_fmt = { 0 }; const struct pixconv *pixconv = NULL; const struct memman *memman = NULL; const struct codec *codec = NULL; struct frame_format dp; int bufsize = BUFFER_SIZE; pthread_t dispt; unsigned flags = OFBP_DOUBLE_BUF; char *test_param = NULL; char *dispdrv = NULL; char *timer_drv = NULL; char *memman_drv = NULL; char *pixconv_drv = NULL; char *codec_drv = NULL; int opt; int ret = 0; #define error(n) do { ret = n; goto out; } while (0) while ((opt = getopt(argc, argv, "b:d:fFM:P:st:T:v:")) != -1) { switch (opt) { case 'b': bufsize = strtol(optarg, NULL, 0) * 1048576; break; case 'd': dispdrv = optarg; break; case 'F': noaspect = 1; case 'f': flags |= OFBP_FULLSCREEN; break; case 'M': memman_drv = optarg; break; case 'P': pixconv_drv = optarg; break; case 's': flags &= ~OFBP_DOUBLE_BUF; break; case 't': test_param = optarg; break; case 'T': timer_drv = optarg; break; case 'v': codec_drv = optarg; break; } } argc -= optind; argv += optind; if (test_param) return speed_test(dispdrv, memman_drv, pixconv_drv, test_param, flags); if (argc < 1) return 1; av_register_all(); avcodec_register_all(); afc = open_file(argv[0]); st = find_stream(afc); if (!st) { fprintf(stderr, "No video streams found.\n"); exit(1); } codec = find_driver(codec_drv, NULL, ofbp_codec_start); if (!codec) { fprintf(stderr, "Decoder '%s' not found\n", codec_drv); error(1); } if (codec->open(NULL, st->codec, &frame_fmt)) { fprintf(stderr, "Error opening decoder\n"); error(1); } if (!frame_fmt.width) { fprintf(stderr, "Decoder error: frame size not specified\n"); error(1); } dp.pixfmt = frame_fmt.pixfmt; display = display_open(dispdrv, &dp, &frame_fmt); if (!display) error(1); set_scale(&dp, &frame_fmt, flags); if (display->memman) { if (dp.pixfmt == frame_fmt.pixfmt) { memman = display->memman; } else if (display->flags & OFBP_PRIV_MEM) { fprintf(stderr, "Decoder/display pixel format mismatch\n"); error(1); } } if (!memman) memman = find_driver(memman_drv, NULL, ofbp_memman_start); if (!memman) error(1); if ((codec->flags & OFBP_PHYS_MEM) && !(memman->flags & OFBP_PHYS_MEM)) { fprintf(stderr, "Incompatible decoder/memman\n"); error(1); } if (memman->alloc_frames(&frame_fmt, bufsize, &frames, &num_frames)) error(1); if (memman != display->memman) { pixconv = pixconv_open(pixconv_drv, &frame_fmt, &dp); if (!pixconv) error(1); if ((pixconv->flags & OFBP_PHYS_MEM) && !(memman->flags & display->flags & OFBP_PHYS_MEM)) { fprintf(stderr, "Incompatible display/memman/pixconv\n"); error(1); } } timer = timer_open(timer_drv); if (!timer) error(1); init_frames(&frame_fmt); if (display->enable(&frame_fmt, flags, pixconv, &dp)) error(1); pthread_mutex_init(&disp_lock, NULL); sem_init(&disp_sem, 0, 0); signal(SIGINT, sigint); pthread_create(&dispt, NULL, disp_thread, st); while (!stop && !av_read_frame(afc, &pk)) { if (pk.stream_index == st->index) if (codec->decode(&pk)) stop = 1; av_free_packet(&pk); } if (!stop) { sem_post(&disp_sem); while (disp_tail != -1) usleep(100000); } stop = 1; sem_post(&disp_sem); pthread_join(dispt, NULL); out: if (afc) av_close_input_file(afc); if (codec) codec->close(); if (timer) timer->close(); if (memman) memman->free_frames(frames, num_frames); if (display) display->close(); if (pixconv) pixconv->close(); return ret; }
static int speed_test(const char *drv, const char *mem, const char *conv, char *size, unsigned disp_flags) { const struct pixconv *pixconv = NULL; const struct memman *memman = NULL; struct frame_format dp = { 0 }; struct frame_format ff = { 0 }; struct timespec t1, t2; unsigned w, h = 0; unsigned n = 1000; unsigned bufsize; char *ss = size; int i, j; w = strtoul(size, &size, 0); if (*size++) h = strtoul(size, &size, 0); if (*size++) n = strtoul(size, NULL, 0); if (!w || !h || !n) { fprintf(stderr, "Invalid size/count '%s'\n", ss); return 1; } ff.width = ALIGN(w, 32); ff.height = ALIGN(h, 32); ff.disp_x = 0; ff.disp_y = 0; ff.disp_w = w; ff.disp_h = h; dp.pixfmt = ff.pixfmt = PIX_FMT_YUV420P; display = display_open(drv, &dp, &ff); if (!display) return 1; set_scale(&dp, &ff, disp_flags); if (display->memman) { memman = display->memman; ff.pixfmt = dp.pixfmt; } if (!memman) memman = find_driver(mem, NULL, ofbp_memman_start); if (memman->alloc_frames(&ff, 0, &frames, &num_frames)) return 1; if (memman != display->memman) { pixconv = pixconv_open(conv, &ff, &dp); if (!pixconv) return 1; if ((pixconv->flags & OFBP_PHYS_MEM) && !(memman->flags & display->flags & OFBP_PHYS_MEM)) { fprintf(stderr, "Incompatible display/memman/pixconv\n"); return 1; } } init_frames(&ff); if (display->enable(&ff, disp_flags, pixconv, &dp)) return 1; bufsize = ff.disp_w * ff.disp_h * 3 / 2; test_pattern(frames, num_frames, &ff); signal(SIGINT, sigint); clock_gettime(CLOCK_REALTIME, &t1); for (i = 0; i < n && !stop; i++) { struct frame *f = ofbp_get_frame(); display->prepare(f); display->show(f); } clock_gettime(CLOCK_REALTIME, &t2); j = ts_diff_ms(&t2, &t1); fprintf(stderr, "%d ms, %d fps, read %lld B/s, write %lld B/s\n", j, i*1000 / j, 1000LL*i*bufsize / j, 2000LL*i*w*h / j); memman->free_frames(frames, num_frames); display->close(); if (pixconv) pixconv->close(); return 0; }