1 /* Copyright (c) 2006-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMDAG_PRIVATE_H
8 #define SIMDAG_PRIVATE_H
12 #include "xbt/dynar.h"
13 #include "simgrid/simdag.h"
14 #include "surf/surf.h"
15 #include "xbt/mallocator.h"
20 /* Global variables */
22 typedef struct SD_global {
23 xbt_mallocator_t task_mallocator; /* to not remalloc new tasks */
25 int watch_point_reached; /* has a task just reached a watch point? */
27 xbt_dynar_t initial_task_set;
28 xbt_dynar_t executable_task_set;
29 xbt_dynar_t completed_task_set;
31 xbt_dynar_t return_set;
34 } s_SD_global_t, *SD_global_t;
36 extern XBT_PRIVATE SD_global_t sd_global;
39 typedef s_xbt_dictelm_t s_SD_storage_t;
40 typedef struct SD_storage {
41 void *data; /* user data */
43 } s_SD_storage_priv_t, *SD_storage_priv_t;
45 static inline SD_storage_priv_t SD_storage_priv(SD_storage_t storage){
46 return (SD_storage_priv_t)xbt_lib_get_level(storage, SD_STORAGE_LEVEL);
50 typedef struct SD_task {
51 e_SD_task_state_t state;
52 void *data; /* user data */
54 e_SD_task_kind_t kind;
56 double alpha; /* used by typed parallel tasks */
60 surf_action_t surf_action;
61 unsigned short watch_points; /* bit field xor()ed with masks */
63 int marked; /* used to check if the task DAG has some cycle*/
66 xbt_dynar_t tasks_before;
67 xbt_dynar_t tasks_after;
68 int unsatisfied_dependencies;
69 unsigned int is_not_ready;
71 /* scheduling parameters (only exist in state SD_SCHEDULED) */
78 long long int counter; /* task unique identifier for instrumentation */
79 char *category; /* sd task category for instrumentation */
82 /* Task dependencies */
83 typedef struct SD_dependency {
88 /* src must be finished before dst can start */
89 } s_SD_dependency_t, *SD_dependency_t;
91 /* SimDag private functions */
92 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
93 XBT_PRIVATE void SD_task_run(SD_task_t task);
94 XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
95 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
97 /* Task mallocator functions */
98 XBT_PRIVATE void* SD_task_new_f(void);
99 XBT_PRIVATE void SD_task_recycle_f(void *t);
100 XBT_PRIVATE void SD_task_free_f(void *t);
102 /* Functions to test if the task is in a given state. */
104 /* Returns whether the given task is scheduled or runnable. */
105 static XBT_INLINE int __SD_task_is_scheduled_or_runnable(SD_task_t task)
107 return task->state == SD_SCHEDULED || task->state == SD_RUNNABLE;
110 /********** Storage **********/
111 XBT_PRIVATE SD_storage_t __SD_storage_create(void *surf_storage, void *data);
112 XBT_PRIVATE void __SD_storage_destroy(void *storage);