view example/add/main.cc @ 1985:d703157bb280 draft

add Read mode in fileread
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Fri, 18 Apr 2014 00:24:16 +0900
parents 4401690b4513
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "TaskManager.h"
#include "Func.h"

extern void task_init(void);
static int task = 1;

const char *usr_help_str = "Usage: ./add \n";
void TMend(TaskManager *);

float A,B,C;

static void
print_result(SchedTask* s,void* a,void* b)
{
    printf("---\n");
    printf("%f + %f = %f \n",A,B,C);
    printf("---\n");
}

void
add_init(TaskManager *manager)
{
    HTask *add;

    A=1.1f, B=2.2f;
    /**
     * Create Task
     *   create_task(Task ID);
     */
    add = manager->create_task(ADD_TASK);
    add->set_cpu(SPE_ANY);

    /**
     * Set of Input Data
     *   add_inData(address of input data, size of input data);
     */
    add->set_inData(0,(memaddr)&A, sizeof(float));
    add->set_inData(1,(memaddr)&B, sizeof(float));

    /**
     * Set of OutPut area
     *   add_outData(address of output area, size of output area);
     */
    add->set_outData(0,(memaddr)&C, sizeof(float));

    /**
     * Set 32bits parameter
     *   add_param(32bit parameter);
     */

    // add Active Queue
    add->set_post(print_result,0,0);
    add->spawn();
}


int
TMmain(TaskManager *manager,int argc, char *argv[])
{
    // Task Register
    //   ppe/task_init.cc
    task_init();

    for (int i = 0; i < task; ++i) {
        add_init(manager);
    }

    //    manager->set_TMend(TMend);

    return 0;
}

// void
// TMend(TaskManager *manager)
// {
//     print_result();
// }