Beispiel #1
0
void eval(char *cmdline) {
    char *argv[MAXARGS];    // argv pour exec
    char buf[MAXLINE];      // contient ligne commande modifiee
    char buf2[MAXLINE];     // pour les substitutions de jobid
                            // par pid pour la commande kill
    strcpy(buf, cmdline);
    bool bg = parseline(buf, argv);

    if (!builtin_command(argv) && replace_kill_jobs(buf2, argv)) {
        int pid;
        if ((pid = Fork()) == 0) {
            exec_command(argv); // Ne retourne jamais
        }

        jobid_t jobid = jobs_add(pid, cmdline);
        if (jobid == INVALID_JOBID) {
            printf("Error while trying to register job with pid %d ", pid);
            printf("Maximum number of jobs (%d) reached ?)\n", MAXJOBS);
        }

        if (bg) {
            job_print_with_pid(jobid);
        }
        else {
            job_fg_wait(jobid, false);
        }
    }

    jobs_print_update();
    exit_forget_next_forced();
}
Beispiel #2
0
int main(void) {
    init();

    serial_putString("Starting up...\r\n");

    /*
     * Create a job description for a blinking LED
     */
    job_t blinkyLedJob = {
        .activationTime = timer_currentTime(),
        .jobFunction = blinkyLed
    };

    /*
     * Create a job description that will check the state of the buttons
     */
    job_t checkButtonsJob = {
        .activationTime = timer_currentTime(),
        .jobFunction = checkButtons
    };

    job_t checkSerialJob = {
        .activationTime = timer_currentTime(),
        .jobFunction = checkUart
    };

    job_t sendI2CJob = {
        .activationTime = timer_currentTime(),
        .jobFunction = sendi2c
    };

    // Add the jobs into the jobs controller
    jobs_add(&blinkyLedJob);
    jobs_add(&checkButtonsJob);
    jobs_add(&checkSerialJob);
    jobs_add(&sendI2CJob);

    while (1) {
        board_update(); // Run the low level operations (buttons, uart...)
        jobs_update(); // Run the jobs
        
        // Go into sleep mode
        //board_idle();
    }

    return 0;
}
int cmp_addjob(int sock,struct tx_struct *data)
{
int ret;
char job_name[400];

	if (cmpstr_min(data->id,"gpvdmaddjob")==0)
	{
		sprintf(job_name,"job%d",njobs);
		jobs_add(job_name,data->target);
		jobs_print();
		return 0;
	}

return -1;
}
Beispiel #4
0
void engine_hostlookup(HOSTLOOKUP *lookup, const char *hostname)
{
	str_copy(lookup->hostname, hostname, sizeof(lookup->hostname));
	jobs_add(&hostlookuppool, &lookup->job, hostlookup_thread, lookup);
}