Ejemplo n.º 1
0
/* Checkpoint signal handler */
static void krg_task_checkpoint(int sig, struct siginfo *info,
				struct pt_regs *regs)
{
	struct epm_action action;
	task_state_t *current_state;
	int r = 0;

	action.type = EPM_CHECKPOINT;
	action.checkpoint.appid = current->application->app_id;

	/*
	 * process must not be frozen while its father
	 * waiting in vfork
	 */
	if (current->vfork_done) {
		mutex_lock(&current->application->mutex);
		r = -EAGAIN;
		app_error("freeze", r, current->application->app_id,
			  "Process %d (%s) has been created by vfork() and has "
			  "not yet called exec(). Thus, its parent process is "
			  "blocked.",
			  task_pid_knr(current), current->comm);
		__set_task_result(current, r);
		mutex_unlock(&current->application->mutex);
		goto out;
	}

	/* freeze */
	current_state = set_result_wait(PCUS_OPERATION_OK);
	if (IS_ERR(current_state))
		goto out;

	/*
	 * checkpoint may be requested several times once
	 * application is frozen.
	 */
	while (current_state->checkpoint.ghost) {
		action.checkpoint.shared = CR_SAVE_LATER;
		r = checkpoint_task(&action, current, regs);

		/* PCUS_OPERATION_OK == 0 */
		current_state = set_result_wait(r);
	}

out:
	return;
}
Ejemplo n.º 2
0
static void task_complete(struct work_queue_task *t)
{
    checkpoint_task(t);

    if(t->result == 0) {
        debug(D_DEBUG, "task complete: %s: %s", t->tag, t->command_line);
        if(strlen(t->output) > 0) {
            char *out = strdup(t->output);
            char *cand1 = malloc(sizeof(char) * 500);
            char *cand2 = malloc(sizeof(char) * 500);
            int dir, start1, start2;
            char *line = strtok(out, "\n");
            int result = sscanf(line, "%s\t%s\t%d\t%d\t%d", cand1, cand2, &dir, &start1, &start2);
            while(result == 5) {
                cand_count++;
                line = strtok(NULL, "\n");
                if(line == NULL) {
                    break;
                }
                result = sscanf(line, "%s\t%s\t%d\t%d\t%d", cand1, cand2, &dir, &start1, &start2);
            }
            free(out);
            free(cand1);
            free(cand2);
        }
        fputs(t->output, outfile);
        fflush(outfile);
        total_processed++;
        tasks_runtime += (t->time_receive_output_finish - t->time_send_input_start);
        tasks_filetime += t->total_transfer_time;
        work_queue_task_delete(t);
    } else {
        debug(D_DEBUG, "task failed: %s: %s", t->tag, t->command_line);

        if(retry_max > total_retried) {
            debug(D_DEBUG, "retrying task %d/%d", total_retried, retry_max);
            total_retried++;
            work_queue_submit(q, t);
        } else {
            fprintf(stderr, "%s: giving up after retrying %d tasks.\n", progname, retry_max);
            exit(1);
        }
    }
}