00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MESH_TYPES_H
00019 #define MESH_TYPES_H
00020
00021 #include <glib.h>
00022 #include <gpriq.h>
00023 #include <mesh.h>
00024
00025 struct mesh_thread_t;
00026 struct mesh_pthread_t;
00027 struct mesh_scheduler_t;
00028 struct mesh_comm_scheduler_t;
00029 struct mesh_interrupt_controller_t;
00030 struct mesh_interrupt_t;
00031 struct mesh_resource_t;
00032 struct mesh_consume_data_t;
00033 struct mesh_resource_thread_pair_t;
00034 struct mesh_feature_power_pair_t;
00035 struct mesh_resource_time_pair_t;
00036 struct mesh_thread_mutex_t;
00037 struct mesh_thread_cond_t;
00038 struct mesh_thread_sem_t;
00039 struct mesh_synchronization_t;
00040 struct mesh_trace_event_t;
00041 struct mesh_shared_data_t;
00042 struct mesh_comm_thread_data_t;
00043 struct mesh_delayed_comm_event_t;
00044 struct mesh_mem_controller_t;
00045 struct mesh_mem_resource_t;
00046 struct mesh_SR_slice_t;
00047 struct mesh_access_statistics_t;
00048 typedef struct mesh_thread_t mesh_thread;
00049 typedef struct mesh_pthread_t mesh_pthread;
00050 typedef struct mesh_scheduler_t mesh_scheduler;
00051 typedef struct mesh_comm_scheduler_t mesh_comm_scheduler;
00052 typedef struct mesh_interrupt_controller_t mesh_interrupt_controller;
00053 typedef struct mesh_interrupt_t mesh_interrupt;
00054 typedef struct mesh_resource_t mesh_resource;
00055 typedef struct mesh_consume_data_t mesh_consume_data;
00056 typedef struct mesh_resource_thread_pair_t mesh_resource_thread_pair;
00057 typedef struct mesh_feature_power_pair_t mesh_feature_power_pair;
00058 typedef struct mesh_resource_time_pair_t mesh_resource_time_pair;
00059 typedef struct mesh_thread_mutex_t mesh_thread_mutex;
00060 typedef struct mesh_thread_cond_t mesh_thread_cond;
00061 typedef struct mesh_thread_sem_t mesh_thread_sem;
00062 typedef struct mesh_synchronization_t mesh_synchronization;
00063 typedef struct mesh_trace_event_t mesh_trace_event;
00064 typedef struct mesh_shared_data_t mesh_shared_data;
00065 typedef struct mesh_memcpy_data_t mesh_memcpy_data;
00066 typedef struct mesh_comm_thread_data_t mesh_comm_thread_data;
00067 typedef struct mesh_delayed_comm_event_t mesh_delayed_comm_event;
00068 typedef struct mesh_mem_controller_t mesh_mem_controller;
00069 typedef struct mesh_mem_resource_t mesh_mem_resource;
00070 typedef struct mesh_SR_slice_t mesh_SR_slice;
00071 typedef struct mesh_access_statistics_t mesh_access_statistics;
00072 typedef GSList mesh_feature_list;
00073 typedef double mesh_time;
00074
00075 struct mesh_scheduler_t {
00076 gchar *name;
00077 GSList *bound_threads;
00078 GSList *eligible_threads;
00079 GSList *controlled_resources;
00080 GSList *(*execute_scheduler)(mesh_scheduler *scheduler);
00081 void (*execute_shared)(mesh_scheduler *, GSList *shared_info, mesh_time);
00082 gint index;
00083 gboolean on_todo_list;
00084
00085 GHashTable *comm_thread_hash;
00086
00087
00088 GHashTable *entry_map;
00089
00090
00091 gboolean is_shared;
00092
00093 mesh_resource *sched_resource;
00094
00095 };
00096
00097 typedef enum { EXEC_THREAD, COMM_THREAD, ISR_THREAD } mesh_thread_type;
00098 typedef enum { POLICY_DEFAULT=-1, POLICY_PINNED, POLICY_COARSE, POLICY_FINE } mesh_scheduling_policy;
00099
00100
00101
00102
00103 struct mesh_comm_scheduler_t {
00104 gchar *name;
00105 GHashTable *comm_thread_hash;
00106
00107 };
00108
00109 struct mesh_pthread_t {
00110
00111
00112 pthread_cond_t cond_local; pthread_mutex_t mutex_local;
00113 pthread_cond_t cond_kernel; pthread_mutex_t mutex_kernel;
00114
00115
00116 gboolean kernel_ready, local_ready;
00117
00118
00119 pthread_t tid;
00120
00121
00122 mesh_thread *ct;
00123 };
00124
00125 struct mesh_thread_t {
00126 gchar *name;
00127
00128 mesh_scheduler *execution_scheduler;
00129 void * (*thread)(void *);
00130
00131 mesh_pthread *pt;
00132
00133
00134
00135
00136
00137
00138
00139 GList *outstanding_consumes;
00140
00141
00142
00143
00144
00145 mesh_consume_data *current_consume;
00146
00147
00148 gint thread_id;
00149
00150
00151 gboolean untimed;
00152
00153
00154 mesh_thread_type type;
00155
00156
00157
00158 gboolean cancel_me;
00159
00160
00161 gboolean squashed;
00162
00163
00164
00165 gboolean finished;
00166
00167
00168 gboolean dead;
00169
00170
00171
00172 mesh_synchronization *stalled;
00173
00174
00175 gboolean started;
00176
00177
00178 mesh_scheduling_policy scheduling_policy;
00179
00180
00181 mesh_resource *last_run_on;
00182
00183
00184
00185
00186 void *user_data;
00187 GHashTable *entry_map;
00188
00189 double user_counter;
00190
00191 double usage;
00192 double contention;
00193
00194
00195
00196
00197 mesh_synchronization *synch;
00198 void *retval;
00199
00200
00201
00202 GSList *delayed_created_threads;
00203 GSList *delayed_free;
00204 GSList *delayed_memcpy;
00205 GSList *delayed_synchronization;
00206 GSList *delayed_comm_events;
00207
00208
00209 GSList *disabled_interrupts;
00210 gboolean all_interrupts_disabled;
00211
00212
00213 void *arg;
00214 };
00215
00216 struct mesh_interrupt_t
00217 {
00218 gchar *name;
00219 gboolean maskable;
00220 void *(*isr)(void *);
00221 void *user_data;
00222 };
00223
00224 struct mesh_interrupt_controller_t
00225 {
00226
00227 void *user_data;
00228
00229
00230
00231 char* (*controller)(void *, GSList **pending);
00232
00233 GHashTable *interrupt_table;
00234
00235
00236 GSList *pending;
00237
00238
00239 GSList *active;
00240 };
00241
00242
00243
00244 struct mesh_SR_slice_t {
00245 mesh_time end_time;
00246 mesh_time length;
00247 GSList *utilization;
00248 mesh_resource *cr;
00249 };
00250
00251 struct mesh_access_statistics_t {
00252 float util;
00253 float align;
00254 };
00255
00256 struct mesh_mem_controller_t {
00257 gchar *name;
00258 gint (*schedule_mem)(gint res_id, gint block_id);
00259 GArray *mem_resource_list;
00260 };
00261
00262 struct mesh_mem_resource_t {
00263 gchar *name;
00264 double time_per_access;
00265
00266
00267 gint mem_res_id;
00268
00269
00270
00271
00272 float (*contention_model)(mesh_access_statistics *);
00273
00274
00275
00276 void (*arbitration_model)(float, GPriq *);
00277 };
00278
00279 struct mesh_resource_t {
00280 gchar *name;
00281 mesh_scheduler *cs;
00282 mesh_thread *last_thread ;
00283
00284 mesh_thread *delay_thread;
00285
00286
00287 mesh_interrupt_controller interrupt_controller;
00288
00289
00290
00291 double (*exec_timing_resolution)(mesh_resource *, GSList *);
00292
00293
00294 double (*sr_timing_resolution)(mesh_resource *, double *);
00295
00296
00297
00298 void (*contention_resolution)(mesh_resource *, GSList *, mesh_time);
00299
00300 mesh_feature_list *cfl;
00301 gboolean idle;
00302 double sr_penalty;
00303 double sch_penalty;
00304
00305 double usage;
00306
00307
00308 double sch_usage;
00309
00310
00311 gint res_id;
00312
00313 gboolean trace_visible;
00314
00315
00316 gboolean shared;
00317
00318 mesh_thread *blocked;
00319
00320 void *user_data;
00321
00322 GHashTable *entry_map;
00323
00324 mesh_mem_controller *mem_controller;
00325
00326
00327
00328 };
00329
00330 struct mesh_consume_data_t {
00331 mesh_time length;
00332 mesh_time end_time;
00333 mesh_time sr_penalty;
00334 mesh_time sch_penalty;
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 GSList *lw_consumes;
00346 GSList *lw_consumes_tail;
00347
00348 GSList *mem_arguments;
00349 GSList *mem_arguments_tail;
00350
00351 mesh_resource *cr;
00352
00353 mesh_thread *ct;
00354 mesh_scheduler *exec_scheduler;
00355 gboolean ends_with_interrupt;
00356 gint slices_processed;
00357
00358
00359 gchar *name;
00360 };
00361
00362 struct mesh_resource_thread_pair_t {
00363 mesh_thread *thread;
00364 mesh_resource *resource;
00365 };
00366
00367 struct mesh_resource_consume_pair_t {
00368 mesh_consume_data *consume_data;
00369 mesh_resource *resource;
00370 };
00371
00372 struct mesh_feature_power_pair_t {
00373 gint feature;
00374 double power;
00375 };
00376
00377 struct mesh_resource_time_pair_t {
00378 mesh_resource *cr;
00379 mesh_time t;
00380 };
00381
00382 struct mesh_thread_mutex_t {
00383 mesh_synchronization *cs;
00384 };
00385
00386 struct mesh_thread_cond_t {
00387 mesh_synchronization *cs;
00388 };
00389
00390 struct mesh_thread_sem_t {
00391 mesh_synchronization *cs;
00392 int semaphore_value;
00393 };
00394
00395 struct mesh_synchronization_t {
00396 GSList *stalled_threads;
00397 int type;
00398 gboolean mutex_flag;
00399 };
00400
00401
00402 struct mesh_trace_event_t {
00403 mesh_time time_step;
00404 mesh_time global_time;
00405 mesh_time mesh_length;
00406 gchar *name;
00407 mesh_resource *resource;
00408 mesh_thread *ct;
00409 mesh_resource *exec_resource;
00410 mesh_thread *exec_thread;
00411 mesh_time sr_penalty;
00412 mesh_time sch_penalty;
00413 gint type;
00414
00415
00416
00417 };
00418
00419 struct mesh_memcpy_data_t {
00420 const void *src;
00421 void *dest;
00422 size_t n;
00423 };
00424
00425 struct mesh_shared_data_t {
00426 int id;
00427 void *data;
00428 int status;
00429
00430
00431
00432
00433
00434 mesh_thread_cond *cond;
00435 mesh_thread_mutex *mutex;
00436 GSList *pending_reads;
00437
00438 };
00439
00440 struct mesh_comm_thread_data_t {
00441 int func;
00442
00443
00444
00445 mesh_shared_data *data;
00446 void *arg;
00447
00448
00449 mesh_resource *exec_resource;
00450 mesh_thread *exec_thread;
00451 };
00452
00453
00454
00455 struct mesh_delayed_comm_event_t {
00456 mesh_scheduler *cs;
00457 gchar *comm_thread;
00458 mesh_comm_thread_data *comm_thread_data;
00459 gchar *thread_name;
00460 gint blocking_mode;
00461 };
00462
00463 #endif