Exemple #1
0
int get_job_no(unsigned int *job_no)
{
	struct control_page* cp = get_ctrl_page();
	if (likely(cp != NULL)) {
		*job_no = cp->job_index;
		return 0;
	} else {
		return -1;
	}
}
Exemple #2
0
int main(int argc, char** argv)
{
    int do_exit, ret;
    struct rt_task param;

    sprintf(myPID,"%d",getpid());
    strcat(filePath,myPID);	
    //argv  1. wcet(ms) 2. period(ms) 3. duration(s) 4. mode (1 for cali sar, 4 for cali kalman) 5. appName 6. size/iter
    
    wcet_f = atoi(argv[1]);    // in ms
    period_f = atof(argv[2]);  // in ms
    size_iter = atof(argv[6]);
    
    wcet_us = (int)(wcet_f*1000);	// Convert ms to us
    
    // wcet_frac = modf(wcet_f,&int_temp);
    // wcet_int = (int)(int_temp);
    
    dur = 1000 * atoi(argv[3]);     // in seconds -> to ms
    mode = atoi(argv[4]);
    count = (dur / period_f);
    
    // printf("wcet_f: %f\tperiod_f: %f\twcet_us: %ld\tcount: %d\n",
    // wcet_f,period_f,wcet_us,count);

    if(argc > 6)
    {
        strncpy(myName,argv[5],40);
    }
    else
    {
        strncpy(myName,"NoNameSet",40);
    }
    printf("Name set: %s\n",myName);
    
    /* Setup task parameters */
    memset(&param, 0, sizeof(param));
    // param.exec_cost = wcet_f * NS_PER_MS;
    // param.period = period_f * NS_PER_MS;
    param.exec_cost = wcet_f * NS_PER_MS;
    param.period = period_f * NS_PER_MS;
    // printf("param.exec: %ld\tparam.period: %ld\n",param.exec_cost, param.period);
    // return 0;
    param.relative_deadline = period_f * NS_PER_MS;
    
    /* What to do in the case of budget overruns? */
    param.budget_policy = NO_ENFORCEMENT;
    
    /* The task class parameter is ignored by most plugins. */
    param.cls = RT_CLASS_SOFT;
    param.cls = RT_CLASS_HARD;
    
    /* The priority parameter is only used by fixed-priority plugins. */
    param.priority = LITMUS_LOWEST_PRIORITY;
    
    /* The task is in background mode upon startup. */
    
    
    /*****
     * 1) Command line paramter parsing would be done here.
     */
    
    
    
    /*****
     * 2) Work environment (e.g., global data structures, file data, etc.) would
     *    be setup here.
     */
    
    
    
    /*****
     * 3) Setup real-time parameters.
     *    In this example, we create a sporadic task that does not specify a
     *    target partition (and thus is intended to run under global scheduling).
     *    If this were to execute under a partitioned scheduler, it would be assigned
     *    to the first partition (since partitioning is performed offline).
     */
    CALL( init_litmus() );
    
    /* To specify a partition, do
     *
     * param.cpu = CPU;
     * be_migrate_to(CPU);
     *
     * where CPU ranges from 0 to "Number of CPUs" - 1 before calling
     * set_rt_task_param().
     */
    CALL( set_rt_task_param(gettid(), &param) );
    
    
    /*****
     * 4) Transition to real-time mode.
     */
    CALL( task_mode(LITMUS_RT_TASK) );
    
    /* The task is now executing as a real-time task if the call didn't fail.
     */
    
    pCtrlPage = get_ctrl_page();

    ret = wait_for_ts_release();
    if (ret != 0)
        printf("ERROR: wait_for_ts_release()");
    
    
    /*****
     * 5) Invoke real-time jobs.
     */
    do {
        /* Wait until the next job is released. */
        sleep_next_period();
        /* Invoke job. */
        do_exit = job();
    } while (!do_exit);
    
    
    
    /*****
     * 6) Transition to background mode.
     */
    CALL( task_mode(BACKGROUND_TASK) );
    
    
    
    /*****
     * 7) Clean up, maybe print results and stats, and exit.
     */
    return 0;
}