int event_add_listener(struct event *evt, void *obj, int (*process_begin) (struct event *evt, void *obj, struct proto_process_stack *stack, unsigned int stack_index), int (*process_end) (struct event *evt, void *obj)) { if (process_begin && process_begin(evt, obj, NULL, 0) != POM_OK) return POM_ERR; struct event_listener *tmp = malloc(sizeof(struct event_listener)); if (!tmp) { pom_oom(sizeof(struct event_listener)); return POM_ERR; } memset(tmp, 0, sizeof(struct event_listener)); tmp->obj = obj; tmp->process_end = process_end; tmp->next = evt->tmp_listeners; if (tmp->next) tmp->next->prev = tmp; evt->tmp_listeners = tmp; registry_perf_inc(evt->reg->perf_listeners, 1); return POM_OK; }
void process_start(void) { //Set up timer A interrupt TACCR0 = 0x00EE;//Period (Timer count value) TACTL = TASSEL_2 + ID_3 + MC_1;//SMCLK clock, Input Divider of 8, Up-mode (count) TACCTL0 = CCIE; // Enable Timer interrupts //Call process_begin()to start execution of processes in queue _disable_interrupt(); process_begin(); }
void FrameProfiler::processFrame() { std::lock_guard<std::mutex> vectorGuard(_eventsMutex); std::sort(_bufferedEvents.begin(), _bufferedEvents.end(), event_sorter); SCP_stringstream stream; SCP_vector<profile_sample> samples; bool start_found = false; bool end_found = false; uint64_t start_profile_time = 0; uint64_t end_profile_time = 0; for (auto& event : _bufferedEvents) { if (!start_found) { start_profile_time = event.timestamp; start_found = true; } if (!end_found) { end_profile_time = event.timestamp; end_found = true; } switch (event.type) { case EventType::Begin: process_begin(samples, event); break; case EventType::End: process_end(samples, event); break; default: break; } } _bufferedEvents.clear(); dump_output(stream, start_profile_time, end_profile_time, samples); content = stream.str(); }
/* * Description: Given an argv and optional envp, launch the process * using the default stdin, stdout, and stderr handles. * Also, register process so that process_wait_for_any_private() * can be used via process_file_io(NULL) or * process_wait_for_any(). * * Returns: * * Notes/Dependencies: */ HANDLE process_easy( char **argv, char **envp) { HANDLE hIn; HANDLE hOut; HANDLE hErr; HANDLE hProcess; if (proc_index >= MAXIMUM_WAIT_OBJECTS) { DB (DB_JOBS, ("process_easy: All process slots used up\n")); return INVALID_HANDLE_VALUE; } if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), GetCurrentProcess(), &hIn, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE) { fprintf(stderr, "process_easy: DuplicateHandle(In) failed (e=%ld)\n", GetLastError()); return INVALID_HANDLE_VALUE; } if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE), GetCurrentProcess(), &hOut, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE) { fprintf(stderr, "process_easy: DuplicateHandle(Out) failed (e=%ld)\n", GetLastError()); return INVALID_HANDLE_VALUE; } if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_ERROR_HANDLE), GetCurrentProcess(), &hErr, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE) { fprintf(stderr, "process_easy: DuplicateHandle(Err) failed (e=%ld)\n", GetLastError()); return INVALID_HANDLE_VALUE; } hProcess = process_init_fd(hIn, hOut, hErr); if (process_begin(hProcess, argv, envp, argv[0], NULL)) { fake_exits_pending++; /* process_begin() failed: make a note of that. */ if (!((sub_process*) hProcess)->last_err) ((sub_process*) hProcess)->last_err = -1; ((sub_process*) hProcess)->exit_code = process_last_err(hProcess); /* close up unused handles */ CloseHandle(hIn); CloseHandle(hOut); CloseHandle(hErr); } process_register(hProcess); return hProcess; }
/* * Description: Given an argv and optional envp, launch the process * using the default stdin, stdout, and stderr handles. * Also, register process so that process_wait_for_any_private() * can be used via process_file_io(NULL) or * process_wait_for_any(). * * Returns: * * Notes/Dependencies: */ HANDLE process_easy( char **argv, char **envp) { HANDLE hIn; HANDLE hOut; HANDLE hErr; HANDLE hProcess; if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), GetCurrentProcess(), &hIn, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE) { fprintf(stderr, "process_easy: DuplicateHandle(In) failed (e=%d)\n", GetLastError()); return INVALID_HANDLE_VALUE; } if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE), GetCurrentProcess(), &hOut, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE) { fprintf(stderr, "process_easy: DuplicateHandle(Out) failed (e=%d)\n", GetLastError()); return INVALID_HANDLE_VALUE; } if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_ERROR_HANDLE), GetCurrentProcess(), &hErr, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE) { fprintf(stderr, "process_easy: DuplicateHandle(Err) failed (e=%d)\n", GetLastError()); return INVALID_HANDLE_VALUE; } hProcess = process_init_fd(hIn, hOut, hErr); if (process_begin(hProcess, argv, envp, argv[0], NULL)) { fake_exits_pending++; ((sub_process*) hProcess)->exit_code = process_last_err(hProcess); /* close up unused handles */ CloseHandle(hIn); CloseHandle(hOut); CloseHandle(hErr); } process_register(hProcess); return hProcess; }