// 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(); } } }
// The following runs "test_app" and sends it various messages. // Used for testing the runtime system. // void run_test_app() { WORKUNIT wu; PROJECT project; APP app; APP_VERSION av; ACTIVE_TASK at; ACTIVE_TASK_SET ats; RESULT result; int retval; char buf[256]; getcwd(buf, sizeof(buf)); // so we can see where we're running gstate.run_test_app = true; wu.project = &project; wu.app = &app; wu.command_line = string("--critical_section"); strcpy(app.name, "test app"); av.init(); av.avg_ncpus = 1; strcpy(result.name, "test result"); result.avp = &av; result.wup = &wu; result.project = &project; result.app = &app; at.result = &result; at.wup = &wu; at.app_version = &av; at.max_elapsed_time = 1e6; at.max_disk_usage = 1e14; at.max_mem_usage = 1e14; strcpy(at.slot_dir, "."); #if 1 // test file copy // ASYNC_COPY* ac = new ASYNC_COPY; FILE_INFO fi; retval = ac->init(&at, &fi, "big_file", "./big_file_copy"); if (retval) { exit(1); } while (1) { do_async_file_ops(); if (at.async_copy == NULL) { break; } } fprintf(stderr, "done\n"); exit(0); #endif ats.active_tasks.push_back(&at); unlink("boinc_finish_called"); unlink("boinc_lockfile"); unlink("boinc_temporary_exit"); unlink("stderr.txt"); retval = at.start(true); if (retval) { fprintf(stderr, "start() failed: %s\n", boincerror(retval)); } while (1) { gstate.now = dtime(); at.preempt(REMOVE_NEVER); ats.poll(); boinc_sleep(.1); at.unsuspend(); ats.poll(); boinc_sleep(.2); //at.request_reread_prefs(); } }