mirror of https://github.com/BOINC/boinc.git
Finished multi-slot functionality
svn path=/trunk/boinc/; revision=381
This commit is contained in:
parent
9b038c99d5
commit
e029476a87
|
@ -1699,3 +1699,14 @@ David August 25, 2002
|
|||
test_uc_win.php
|
||||
tools/
|
||||
add.C
|
||||
|
||||
Eric August 26, 2002
|
||||
- Finished multi-slot functionality. The client now requests an
|
||||
open slot from the ACTIVE_TASK_SET which will be the slot
|
||||
for the new process.
|
||||
|
||||
client/
|
||||
app.C
|
||||
app.h
|
||||
cs_apps.C
|
||||
|
||||
|
|
29
client/app.C
29
client/app.C
|
@ -648,6 +648,35 @@ bool ACTIVE_TASK_SET::poll_time() {
|
|||
return updated;
|
||||
}
|
||||
|
||||
// Gets the next available free slot, or returns -1 if all slots are full
|
||||
//
|
||||
int ACTIVE_TASK_SET::get_free_slot(int total_slots) {
|
||||
int start_slot,i;
|
||||
char *slot_status;
|
||||
|
||||
if (active_tasks.size() >= total_slots)
|
||||
return -1;
|
||||
|
||||
slot_status = (char *)calloc( sizeof(char), total_slots );
|
||||
if (!slot_status) return -1;
|
||||
|
||||
for (i=0; i<active_tasks.size(); i++) {
|
||||
if (active_tasks[i]->slot >= 0 && active_tasks[i]->slot < total_slots) {
|
||||
slot_status[active_tasks[i]->slot] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<total_slots; i++) {
|
||||
if (!slot_status[i]) {
|
||||
free(slot_status);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
free(slot_status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Write XML data about this ACTIVE_TASK
|
||||
//
|
||||
int ACTIVE_TASK::write(FILE* fout) {
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
void unsuspend_all();
|
||||
int restart_tasks();
|
||||
void exit_tasks();
|
||||
int get_free_slot(int total_slots);
|
||||
|
||||
int write(FILE*);
|
||||
int parse(FILE*, CLIENT_STATE*);
|
||||
|
|
|
@ -151,11 +151,14 @@ bool CLIENT_STATE::start_apps() {
|
|||
RESULT* rp;
|
||||
ACTIVE_TASK* atp;
|
||||
bool action = false;
|
||||
int open_slot;
|
||||
|
||||
for (i=0; i<results.size(); i++) {
|
||||
// If all the app slots are already used, we can't start
|
||||
// a new app
|
||||
if (active_tasks.active_tasks.size() == nslots) {
|
||||
open_slot = active_tasks.get_free_slot(nslots);
|
||||
|
||||
if (open_slot < 0) {
|
||||
if (log_flags.task_debug) {
|
||||
printf("start_apps(): all slots full\n");
|
||||
}
|
||||
|
@ -172,6 +175,7 @@ bool CLIENT_STATE::start_apps() {
|
|||
}
|
||||
rp->is_active = true;
|
||||
atp = new ACTIVE_TASK;
|
||||
atp->slot = open_slot;
|
||||
atp->init(rp);
|
||||
active_tasks.insert(atp);
|
||||
action = true;
|
||||
|
|
Loading…
Reference in New Issue