void runner::resume() { suspend_mutex_.lock(); if (get_process_status() != process_suspended) { suspend_mutex_.unlock(); return; } enumerate_threads_([](handle_t handle) { ResumeThread(handle); }); process_status = process_still_active; get_process_status(); suspend_mutex_.unlock(); }
bool runner::wait_for(const unsigned long &interval) { if (get_process_status() == process_spawner_crash || get_process_status() & process_finished_normal) { return true; } if (!running_async) { return false; } wait_for_init(interval); if (WaitForSingleObject(process_info.hProcess, interval) != WAIT_OBJECT_0) { return false; } WaitForSingleObject(running_thread, interval); CloseHandleSafe(running_thread); return true; }
void runner::run_process() { if (options.debug && !running_async) { run_process_async(); WaitForSingleObject(running_thread, 100);//may stuck here WaitForSingleObject(init_semaphore, INFINITE);//may stuck here WaitForSingleObject(process_info.hProcess, INFINITE);//may stuck here return; } create_process(); if (get_process_status() == process_spawner_crash || get_process_status() & process_finished_normal) { return; } running = true; requisites(); if (get_process_status() == process_spawner_crash || get_process_status() & process_finished_normal) { return; } wait(); }
/** * @brief ioctl communicaton function * communicaton with application * @param data passed from application memory space * * @return communicaton status */ static long driver_ioctl(struct file *f, unsigned int cmd, unsigned long arg) { int ret = 0; uint32_t mess; switch (cmd){ case SET_IMAGE_STATUS: if (copy_from_user(&mess, (void __user *)arg, sizeof(unsigned int))) return COMMUNICATION_ERROR; /* Send message to nios */ ret = mbox_send_message(chan_sender, (void *)&mess); pr_info("%s image is sent to nios, size: %d", __func__, mess); if (ret < 0) pr_info("Message 1 failure\n"); set_process_status(PROCESS_START); if(__put_user(ret, (unsigned int __user *)arg)) return COMMUNICATION_ERROR; break; case GET_IMAGE_STATUS: mess = get_process_status(); /* * Return image status * If process_status is 0, * Nios did not finish to process the last request */ if(__put_user(mess, (unsigned int __user *)arg)) return COMMUNICATION_ERROR; break; default: break; } return ret; }
bool runner::is_running() { return running || ((get_process_status() & process_still_active) != 0); }
exception_t runner::get_exception() { if (get_process_status() == process_finished_abnormally) { return (exception_t)get_exit_code(); } else return exception_exception_no; }