本文整理汇总了C++中ACTIVE_TASK类的典型用法代码示例。如果您正苦于以下问题:C++ ACTIVE_TASK类的具体用法?C++ ACTIVE_TASK怎么用?C++ ACTIVE_TASK使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACTIVE_TASK类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kill_tasks
// Send kill signal to all app processes
// Don't wait for them to exit
//
void ACTIVE_TASK_SET::kill_tasks(PROJECT* proj) {
unsigned int i;
ACTIVE_TASK *atp;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (proj && atp->wup->project != proj) continue;
if (!atp->process_exists()) continue;
atp->kill_task(false);
}
}
示例2: upload_notify_app
// a file upload has finished.
// If any running apps are waiting for it, notify them
//
void ACTIVE_TASK_SET::upload_notify_app(FILE_INFO* fip) {
for (unsigned int i=0; i<active_tasks.size(); i++) {
ACTIVE_TASK* atp = active_tasks[i];
RESULT* rp = atp->result;
FILE_REF* frp = rp->lookup_file(fip);
if (frp) {
atp->upload_notify_app(fip, frp);
}
}
}
示例3: init
void ACTIVE_TASK_SET::init() {
for (unsigned int i=0; i<active_tasks.size(); i++) {
ACTIVE_TASK* atp = active_tasks[i];
atp->init(atp->result);
atp->scheduler_state = CPU_SCHED_PREEMPTED;
atp->read_task_state_file();
atp->current_cpu_time = atp->checkpoint_cpu_time;
atp->elapsed_time = atp->checkpoint_elapsed_time;
}
}
示例4: network_available
void ACTIVE_TASK_SET::network_available() {
#ifndef SIM
for (unsigned int i=0; i<active_tasks.size(); i++) {
ACTIVE_TASK* atp = active_tasks[i];
if (atp->want_network) {
atp->send_network_available();
}
}
#endif
}
示例5: LOGD
// Send quit message to all app processes
// This is called when the core client exits,
// or when a project is detached or reset
//
void ACTIVE_TASK_SET::request_tasks_exit(PROJECT* proj) {
LOGD("app_control: ACTIVE_TASK::request_tasks_exit");
unsigned int i;
ACTIVE_TASK *atp;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (proj && atp->wup->project != proj) continue;
if (!atp->process_exists()) continue;
atp->request_exit();
}
}
示例6: request_reread_prefs
// tell all running apps of a project to reread prefs
//
void ACTIVE_TASK_SET::request_reread_prefs(PROJECT* project) {
unsigned int i;
ACTIVE_TASK* atp;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (atp->result->project != project) continue;
if (!atp->process_exists()) continue;
atp->request_reread_prefs();
}
}
示例7: check_rsc_limits_exceeded
// Check if any of the active tasks have exceeded their
// resource limits on disk, CPU time or memory
//
bool ACTIVE_TASK_SET::check_rsc_limits_exceeded() {
unsigned int i;
ACTIVE_TASK *atp;
static double last_disk_check_time = 0;
bool do_disk_check = false;
bool did_anything = false;
double ram_left = gstate.available_ram();
double max_ram = gstate.max_available_ram();
// Some slot dirs have lots of files,
// so only check every min(disk_interval, 300) secs
//
double min_interval = gstate.global_prefs.disk_interval;
if (min_interval < 300) min_interval = 300;
if (gstate.now > last_disk_check_time + min_interval) {
do_disk_check = true;
}
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (atp->task_state() != PROCESS_EXECUTING) continue;
if (!atp->result->project->non_cpu_intensive && (atp->elapsed_time > atp->max_elapsed_time)) {
msg_printf(atp->result->project, MSG_INFO,
"Aborting task %s: exceeded elapsed time limit %f\n",
atp->result->name, atp->max_elapsed_time
);
atp->abort_task(ERR_RSC_LIMIT_EXCEEDED, "Maximum elapsed time exceeded");
did_anything = true;
continue;
}
if (atp->procinfo.working_set_size_smoothed > max_ram) {
msg_printf(atp->result->project, MSG_INFO,
"Aborting task %s: exceeded memory limit %.2fMB > %.2fMB\n",
atp->result->name,
atp->procinfo.working_set_size_smoothed/MEGA, max_ram/MEGA
);
atp->abort_task(ERR_RSC_LIMIT_EXCEEDED, "Maximum memory exceeded");
did_anything = true;
continue;
}
if (do_disk_check && atp->check_max_disk_exceeded()) {
did_anything = true;
continue;
}
ram_left -= atp->procinfo.working_set_size_smoothed;
}
if (ram_left < 0) {
gstate.request_schedule_cpus("RAM usage limit exceeded");
}
if (do_disk_check) {
last_disk_check_time = gstate.now;
}
return did_anything;
}
示例8: is_task_executing
// Check to see if any tasks are running
// called if benchmarking and waiting for suspends to happen
// or the system needs to suspend itself so we are suspending
// the applications
//
bool ACTIVE_TASK_SET::is_task_executing() {
unsigned int i;
ACTIVE_TASK* atp;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (atp->task_state() == PROCESS_EXECUTING) {
return true;
}
}
return false;
}
示例9: graphics_poll
void ACTIVE_TASK_SET::graphics_poll() {
unsigned int i;
ACTIVE_TASK* atp;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (!atp->process_exists()) continue;
atp->graphics_request_queue.msg_queue_poll(
atp->app_client_shm.shm->graphics_request
);
atp->check_graphics_mode_ack();
}
}
示例10: compute_temp_dcf
// compute a per-app-version "temporary DCF" based on the elapsed time
// and fraction done of running jobs
//
void compute_temp_dcf() {
unsigned int i;
for (i=0; i<gstate.app_versions.size(); i++) {
gstate.app_versions[i]->temp_dcf = 1;
}
for (i=0; i<gstate.active_tasks.active_tasks.size(); i++) {
ACTIVE_TASK* atp = gstate.active_tasks.active_tasks[i];
double x = atp->est_dur(false) / atp->result->estimated_duration(false);
APP_VERSION* avp = atp->result->avp;
if (x < avp->temp_dcf) {
avp->temp_dcf = x;
}
}
}
示例11: unsuspend_all
// resume all currently scheduled tasks
//
void ACTIVE_TASK_SET::unsuspend_all() {
unsigned int i;
ACTIVE_TASK* atp;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (atp->scheduler_state != CPU_SCHED_SCHEDULED) continue;
if (atp->task_state() == PROCESS_UNINITIALIZED) {
if (atp->start(false)) {
msg_printf(atp->wup->project, MSG_INTERNAL_ERROR,
"Couldn't restart task %s", atp->result->name
);
}
} else if (atp->task_state() == PROCESS_SUSPENDED) {
atp->unsuspend();
}
}
}
示例12: handle_get_screensaver_tasks
static void handle_get_screensaver_tasks(MIOFILE& fout) {
unsigned int i;
ACTIVE_TASK* atp;
fout.printf(
"<handle_get_screensaver_tasks>\n"
" <suspend_reason>%d</suspend_reason>\n",
gstate.suspend_reason
);
for (i=0; i<gstate.active_tasks.active_tasks.size(); i++) {
atp = gstate.active_tasks.active_tasks[i];
if ((atp->task_state() == PROCESS_EXECUTING) ||
((atp->task_state() == PROCESS_SUSPENDED) && (gstate.suspend_reason == SUSPEND_REASON_CPU_THROTTLE))) {
atp->result->write_gui(fout);
}
}
fout.printf("</handle_get_screensaver_tasks>\n");
}
示例13: handle_result_op
static void handle_result_op(GUI_RPC_CONN& grc, const char* op) {
RESULT* rp;
char result_name[256];
ACTIVE_TASK* atp;
string project_url;
strcpy(result_name, "");
while (!grc.xp.get_tag()) {
if (grc.xp.parse_str("name", result_name, sizeof(result_name))) continue;
if (grc.xp.parse_string("project_url", project_url)) continue;
}
PROJECT* p = get_project(grc, project_url);
if (!p) return;
if (!strlen(result_name)) {
grc.mfout.printf("<error>Missing result name</error>\n");
return;
}
rp = gstate.lookup_result(p, result_name);
if (!rp) {
grc.mfout.printf("<error>no such result</error>\n");
return;
}
if (!strcmp(op, "abort")) {
msg_printf(p, MSG_INFO, "task %s aborted by user", result_name);
atp = gstate.lookup_active_task_by_result(rp);
if (atp) {
atp->abort_task(EXIT_ABORTED_VIA_GUI, "aborted by user");
} else {
rp->abort_inactive(EXIT_ABORTED_VIA_GUI);
}
gstate.request_work_fetch("result aborted by user");
} else if (!strcmp(op, "suspend")) {
msg_printf(p, MSG_INFO, "task %s suspended by user", result_name);
rp->suspended_via_gui = true;
gstate.request_work_fetch("result suspended by user");
} else if (!strcmp(op, "resume")) {
msg_printf(p, MSG_INFO, "task %s resumed by user", result_name);
rp->suspended_via_gui = false;
}
gstate.request_schedule_cpus("result suspended, resumed or aborted by user");
gstate.set_client_state_dirty("Result RPC");
grc.mfout.printf("<success/>\n");
}
示例14: get_msgs
// check for msgs from active tasks,
// and update their elapsed time and other info
//
void ACTIVE_TASK_SET::get_msgs() {
//LOGD("app_control: ACTIVE_TASK::get_msgs");
unsigned int i;
ACTIVE_TASK *atp;
double old_time;
static double last_time=0;
double delta_t;
if (last_time) {
delta_t = gstate.now - last_time;
// Normally this is called every second.
// If delta_t is > 10, we'll assume that a period of hibernation
// or suspension happened, and treat it as zero.
// If negative, must be clock reset. Ignore.
//
if (delta_t > 10 || delta_t < 0) {
delta_t = 0;
}
} else {
delta_t = 0;
}
last_time = gstate.now;
for (i=0; i<active_tasks.size(); i++) {
atp = active_tasks[i];
if (!atp->process_exists()) continue;
old_time = atp->checkpoint_cpu_time;
if (atp->task_state() == PROCESS_EXECUTING) {
atp->elapsed_time += delta_t;
}
if (atp->get_app_status_msg()) {
if (old_time != atp->checkpoint_cpu_time) {
char buf[256];
sprintf(buf, "%s checkpointed", atp->result->name);
if (atp->overdue_checkpoint) {
gstate.request_schedule_cpus(buf);
}
atp->checkpoint_wall_time = gstate.now;
atp->premature_exit_count = 0;
atp->checkpoint_elapsed_time = atp->elapsed_time;
atp->checkpoint_fraction_done = atp->fraction_done;
atp->checkpoint_fraction_done_elapsed_time = atp->fraction_done_elapsed_time;
if (log_flags.checkpoint_debug) {
msg_printf(atp->wup->project, MSG_INFO,
"[checkpoint] result %s checkpointed",
atp->result->name
);
} else if (log_flags.task_debug) {
msg_printf(atp->wup->project, MSG_INFO,
"[task] result %s checkpointed",
atp->result->name
);
}
atp->write_task_state_file();
}
}
atp->get_trickle_up_msg();
atp->get_graphics_msg();
}
}
示例15: while
// clean up after finished apps
//
bool CLIENT_STATE::handle_finished_apps() {
ACTIVE_TASK* atp;
bool action = false;
static double last_time = 0;
if (!clock_change && now - last_time < HANDLE_FINISHED_APPS_PERIOD) return false;
last_time = now;
vector<ACTIVE_TASK*>::iterator iter;
iter = active_tasks.active_tasks.begin();
while (iter != active_tasks.active_tasks.end()) {
atp = *iter;
switch (atp->task_state()) {
case PROCESS_EXITED:
case PROCESS_WAS_SIGNALED:
case PROCESS_EXIT_UNKNOWN:
case PROCESS_COULDNT_START:
case PROCESS_ABORTED:
if (log_flags.task) {
msg_printf(atp->wup->project, MSG_INFO,
"Computation for task %s finished", atp->result->name
);
}
app_finished(*atp);
if (!action) {
adjust_rec(); // update REC before erasing ACTIVE_TASK
}
iter = active_tasks.active_tasks.erase(iter);
delete atp;
set_client_state_dirty("handle_finished_apps");
// the following is critical; otherwise the result is
// still in the "scheduled" list and enforce_schedule()
// will try to run it again.
//
request_schedule_cpus("handle_finished_apps");
action = true;
break;
default:
++iter;
}
}
return action;
}