Task.h

Go to the documentation of this file.
00001 #ifndef TASK_H
00002 #define TASK_H
00003 
00004 #include <pthread.h>
00005 #include "TaskIdList.h"
00006 //#include "constants.h"
00007 #include "DataSpace.h"
00008 #include "cser.h"
00009 
00010 
00011 #define KEY_INT
00012 #define VAL_VOID
00013 #include "hash.h"
00014 #undef VAL_VOID
00015 #undef KEY_INT
00016 
00017 
00018 typedef enum {created, running, finished} TaskState_t;
00019 
00020 typedef struct _task_ {
00021         TaskIdList *myDeps; ///< Task that this task has data dependencies
00022         TaskIdList *dependsOnMe; ///< Tasks that have data dependencies on this task
00023         HashIntVoid *children; ///< Tasks that where created by this task. The key is a integer (not a DSI) because a task cannot have children in other works
00024         int id;                                 ///< The task id
00025         struct _task_ *mother; ///< The task that created this task
00026         int endedTasks;
00027         char *metadata;
00028         int metaSize;
00029         TaskState_t state;
00030         DataSpace *dataSpace;
00031 }Task;
00032 
00033 // Threads task struct field access:
00034 //                              Checkpointed Task:                      Checkpointed Task Child:
00035 // State:               finished                                        any (writing coud be delayed)
00036 // Thread:              Worker:         Writer:                 Worker          Writer
00037 // mydeps:              read            read                    read            read
00038 // dependsOnMe: sync write      sync read               sync write      sync read
00039 // children:    write1          read                    write           -
00040 // id                   -                       read                    write2          read
00041 // mother               -                       -                               write2          -
00042 // endedTasks   -                       read                    write           -
00043 // metadata             read            read                    read            read
00044 // metaSize             read            read                    read            read
00045 // state                read            read                    write           -               
00046 // DataSpace    read            read                    write           -
00047 
00048 // 1: Before task checkpoint
00049 // 2: Before mother chechpoint
00050  
00051 
00052 /////////////////// SETS ////////////////////////
00053 Task *createTask();
00054 
00055 void destroyTask(Task *task);
00056 
00057 void setTaskEndedTasks(Task *task, int endedTasks);
00058 
00059 void setTaskState(Task *task, TaskState_t state);
00060 
00061 void setTaskMetadata(Task *task, const char *metadata, const int metaSize);
00062 
00063 void setTaskMyDeps(Task *task, TaskIdList *list);
00064 
00065 // MARRETA:::: Esse eh o unico set q nao permite vc dar
00066 // free na estrutura passada.. isso pq o Hash nao implementa
00067 // clone()
00068 void setTaskDataSpace(Task *task, DataSpace *dataSpace);
00069 
00070 void setTaskDependsOnMe(Task *task, TaskIdList *list);
00071 
00072 void setTaskMother(Task *task, Task *mother);
00073 
00074 void setTaskId(Task *task, int id);
00075 
00076 void addTaskToDependsOnMe(Task *task, int taskId);
00077 
00078 void taskAddChild(Task *mother, int childId, Task *child);
00079 
00080 HashIntVoid *taskTakeChildren(Task *task);
00081 
00082 void taskMove(Task *dest, Task *src);
00083 
00084 /*----------------------------- GETS -------------------------------*/
00085 int getTaskEndedTasks(Task *task);
00086 
00087 int getTaskMetasize(Task *task);
00088 
00089 TaskState_t getTaskState(Task *task);
00090 
00091 char *getTaskMetadata(Task *task);
00092 
00093 TaskIdList *getTaskMyDeps(Task *task);
00094 
00095 TaskIdList *getTaskDependsOnMe(Task *task);
00096 
00097 HashIntVoid *getTaskChildren(Task *task);
00098 
00099 DataSpace *getTaskDataSpace(Task *task);
00100 
00101 Task *getTaskMother(Task *task);
00102 
00103 int getTaskId(Task *task);
00104 
00105 ////////////// Funcs to write the Task to File/////////////////
00106 
00107 int writeTask(FILE *outputFile, void *task);
00108 void *readTask(FILE *inputFile);
00109 
00110 int writeChildTask(FILE *outputFile, void *task);
00111 void *readChildTask(FILE *inputFile);
00112 
00113 int compareTasks(Task *task1, Task *task2);
00114 
00115 #endif

Generated on Tue Jan 17 19:18:39 2006 for Void by  doxygen 1.4.6