drake  1.0.0
include/drake/task.h
Go to the documentation of this file.
00001 /*
00002  Copyright 2015 Nicolas Melot
00003 
00004  This file is part of Drake.
00005 
00006  Drake is free software: you can redistribute it and/or modify
00007  it under the terms of the GNU General Public License as published by
00008  the Free Software Foundation, either version 3 of the License, or
00009  (at your option) any later version.
00010 
00011  Drake is distributed in the hope that it will be useful,
00012  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  GNU General Public License for more details.
00015 
00016  You should have received a copy of the GNU General Public License
00017  along with Drake. If not, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #include <pelib/string.h>
00022 #include <pelib/integer.h>
00023 #include <stddef.h>
00024 
00025 #ifndef TASK_H
00026 #define TASK_H
00027 
00028 enum task_status {TASK_INVALID, TASK_INIT, TASK_START, TASK_RUN, TASK_KILLED, TASK_ZOMBIE, TASK_DESTROY};
00030 typedef enum task_status task_status_t;
00031 
00033 typedef unsigned int task_id;
00034 
00036 struct link;
00038 typedef struct link link_t;
00040 typedef link_t* link_tp;
00041 
00043 #define STRUCT_T link_t
00044 #include <pelib/structure.h>
00045 #define DONE_link_t 1
00046 
00048 #define STRUCT_T link_tp
00049 #include <pelib/structure.h>
00050 #define DONE_link_tp 1
00051 
00052 #define PAIR_KEY_T string
00053 #define PAIR_VALUE_T link_tp
00054 #include <pelib/pair.h>
00055 #define DONE_pair_string_link_tp 1
00056 
00057 #define ITERATOR_T pair_t(string, link_tp)
00058 #include <pelib/iterator.h>
00059 #define DONE_iterator_pair_string_link_tp 1
00060 
00062 #define MAP_KEY_T string
00063 #define MAP_VALUE_T link_tp
00064 #include <pelib/map.h>
00065 #define DONE_map_string_link_tp 1
00066 
00067 #define ARRAY_T link_tp
00068 #include <pelib/array.h>
00069 #define DONE_array_link_tp 1
00070 
00072 struct cross_link;
00074 typedef struct cross_link cross_link_t;
00076 typedef cross_link_t* cross_link_tp;
00077 
00079 #define STRUCT_T cross_link_t
00080 #include <pelib/structure.h>
00081 #define DONE_cross_link_t 1
00082 
00084 #define STRUCT_T cross_link_tp
00085 #include <pelib/structure.h>
00086 #define DONE_cross_link_tp 1
00087 
00088 #define PAIR_KEY_T string
00089 #define PAIR_VALUE_T cross_link_tp
00090 #include <pelib/pair.h>
00091 #define DONE_pair_string_cross_link_tp 1
00092 
00093 #define ITERATOR_T pair_t(string, cross_link_tp)
00094 #include <pelib/iterator.h>
00095 #define DONE_iterator_pair_string_cross_link_tp 1
00096 
00098 #define MAP_KEY_T string
00099 #define MAP_VALUE_T cross_link_tp
00100 #include <pelib/map.h>
00101 #define DONE_map_string_cross_link_tp 1
00102 
00103 #define ARRAY_T cross_link_tp
00104 #include <pelib/array.h>
00105 #define DONE_array_cross_link_tp 1
00106 
00108 struct processor;
00110 typedef struct processor processor_t;
00111 
00113 struct task
00114 {
00116         task_id id;
00118         processor_t **core;
00119         size_t width;
00121         map_t(string, link_tp) *succ;
00123         map_t(string, link_tp) *pred;
00125         //map_t(string, cross_link_tp) *sink;
00126         array_t(cross_link_tp) *sink;
00128         //map_t(string, cross_link_tp) *source;
00129         array_t(cross_link_tp) *source;
00131         int frequency;
00132         double workload;
00134         task_status_t status;
00136         char *name;
00138         int (*init)(struct task*, void*);
00140         int (*start)(struct task*);
00142         int (*run)(struct task*);
00144         int (*kill)(struct task*);
00146         int (*destroy)(struct task*);
00148         unsigned long long int start_time, stop_time, start_presort, stop_presort, check_time, push_time, work_time, check_errors, check_recv, check_putback, check_feedback, put_reset, put_pop, put_send, check_wait, push_wait, work_wait, work_read, work_write;
00150         unsigned long long int step_init, step_start, step_check, step_work, step_push, step_killed, step_zombie, step_transition;
00151 };
00153 typedef struct task task_t;
00155 typedef struct task* task_tp;
00156 
00158 #define STRUCT_T task_t
00159 #include <pelib/structure.h>
00160 #define DONE_task_t 1
00161 
00163 #define STRUCT_T task_tp
00164 #include <pelib/structure.h>
00165 #define DONE_task_tp 1
00166 
00167 #define PAIR_KEY_T string
00168 #define PAIR_VALUE_T task_tp
00169 #include <pelib/pair.h>
00170 #define DONE_pair_string_task_tp 1
00171 
00172 #define ITERATOR_T pair_t(string, task_tp)
00173 #include <pelib/iterator.h>
00174 #define DONE_iterator_string_task_tp 1
00175 
00176 #define MAP_KEY_T string
00177 #define MAP_VALUE_T task_tp
00178 #include <pelib/map.h>
00179 #define DONE_map_string_task_tp 1
00180 
00182 #define ARRAY_T task_tp
00183 #include <pelib/array.h>
00184 #define DONE_array_task_tp 1
00185 
00187 int
00188 drake_task_depleted(task_tp task);
00189 
00190 int
00191 drake_task_killed(task_tp task);
00192 #endif