diff --git a/include/monitoring/trace_manager.h b/include/monitoring/trace_manager.h index 7902d378f007b4d8cab50d8a866b458e3cc18c73..a9aa8c8ebfa4de1746d39c4e5d62623081d0eae0 100644 --- a/include/monitoring/trace_manager.h +++ b/include/monitoring/trace_manager.h @@ -2,14 +2,20 @@ #include #include -/** Nature of the task traced */ +/** + * \enum events. + * \brief Nature of the task traced. + */ typedef enum { PERIODIC = 1, SPORADIC = -1, ANY = 0, } events; -/** Step in which the traced-task is */ +/** + * \enum steps. + * \brief Step in which the traced-task is. + */ typedef enum { /* The task has just been creatd */ CREATION = 0, @@ -19,7 +25,10 @@ typedef enum { GET_VALUE = 4, } steps; -/** Structure stored when an event is recorded */ +/** + * \struct characteristics. + * \brief Structure stored when an event is recorded. + */ typedef struct characteristics characteristics; struct characteristics{ @@ -34,20 +43,32 @@ struct characteristics{ __po_hi_request_t *p_request; }; -/** Function initializing the mutex */ +/** + * \brief Function initializing the mutex. + */ void trace_initialize(); -/** Function used to trace a task. */ -/* The stored events (under the form of "characteristics" structures) are sent in an array +/** + * \brief Function used to trace a task. + * + * The stored events (under the form of "characteristics" structures) are sent in an array * and written in the history.txt file. - * t_id is the task_id. - * p_src and p_dest are the GLOBAL source and destination ports if they exists / are retrievable. - * port_src and port_dest are the LOCAL source and destination ports if they exists / are retrievable. - * p_req is a pointer toward the request if it exists and is retrievable. - * CONVENTION : + * + * WARNING. * If an operation is made without movement, that is to say with no source or destination (such as waiting for an event), * the concerned port is stored in the "src" port. -*/ + * + * \param event The nature of the task. + * \param status The step in which the task is. + * \param task_id Identifier of the task. + * \param p_src and p_dest, the GLOBAL source and destination ports if they exists / are retrievable. + * \param port_src and port_dest, the LOCAL source and destination ports if they exists / are retrievable. + * \param p_req a pointer toward the request if it exists and is retrievable. + * + * \return __PO_HI_SUCCESS if successful. + * \return __PO_HI_INVALID if there is an error with the txt file. + * \return __PO_HI_UNAVAILABLE is the time isn't retrievable. + */ int record_event (int event, int status, diff --git a/src/monitoring/trace_manager.c b/src/monitoring/trace_manager.c index 794d5f795eb6156deaeb68058ec1fb9ea347acb8..71e6788c69871ff6861a973c1cf1b4b028239443 100644 --- a/src/monitoring/trace_manager.c +++ b/src/monitoring/trace_manager.c @@ -22,11 +22,11 @@ __po_hi_mutex_t __po_hi_c_trace_mutex; -/** Array receiving all tasks */ +/* Array receiving all tasks */ characteristics task_log[MAX_STRUCT]; -/** Integer allowing to move in the task_log array */ +/* Integer allowing to move in the task_log array */ int nb_struct = 0; -/** Initializing the mutex in the main.c */ +/* Initializing the mutex in the main.c */ void trace_initialize(){ __po_hi_mutex_init (&__po_hi_c_trace_mutex,__PO_HI_MUTEX_REGULAR, 0); } @@ -34,31 +34,31 @@ void trace_initialize(){ -/** Recording all events, trace_managing */ +/* Recording all events, trace_managing */ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src, __po_hi_port_t p_dest, __po_hi_local_port_t port_src,__po_hi_local_port_t port_dest, __po_hi_request_t *p_req){ - /** CREATION OF STREAM */ + /* CREATION OF STREAM */ printf("IN PROGRAM"); FILE *history = NULL; - /** CREATION OF THE STRUCTURE TO BE SENT TO TASK_LOG */ + /* CREATION OF THE STRUCTURE TO BE SENT TO TASK_LOG */ characteristics my_task; characteristics *p_my_task = &my_task; - /** EVENT */ + /* EVENT */ events ev = event; p_my_task->event = ev; - /** STATUS */ + /* STATUS */ steps step = stat; p_my_task->status = step; - /** TASK ID */ + /* TASK ID */ p_my_task->task_id = t_id; - /** GLOBAL PORT SRC */ + /* GLOBAL PORT SRC */ p_my_task->global_port_src = p_src; - /** GLOBAL PORT DEST */ + /* GLOBAL PORT DEST */ p_my_task->global_port_dest = p_dest; - /** PORT LOCAL SRC */ + /* PORT LOCAL SRC */ p_my_task->loc_port_src = port_src; - /** PORT LOCAL DEST */ + /* PORT LOCAL DEST */ p_my_task->loc_port_dest = port_dest; - /** TIME */ + /* TIME */ __po_hi_time_t time; int gettime = __po_hi_get_time (&time); if (gettime == __PO_HI_SUCCESS){ @@ -68,18 +68,18 @@ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src printf("Can't get the time, break"); return __PO_HI_UNAVAILABLE; } - /** REQUEST */ + /* REQUEST */ p_my_task->p_request = malloc (sizeof(__po_hi_request_t)); if (p_req != NULL){ memcpy(p_my_task->p_request, p_req, sizeof(__po_hi_request_t)); } - /** LOCKING THE MUTEX */ + /* LOCKING THE MUTEX */ printf("lock"); __po_hi_mutex_lock (&__po_hi_c_trace_mutex); printf("locked"); - /** IF the log array is complete */ + /* IF the log array is complete */ if (nb_struct >= 10){ /* A stream is opened */ printf("open"); @@ -103,13 +103,13 @@ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src fclose(history); } - /** If the log array isn't complete, write in it */ + /* If the log array isn't complete, write in it */ if (nb_struct < 10){ task_log[nb_struct] = my_task; nb_struct += 1; } - /** UNLOCKING THE MUTEX */ + /* UNLOCKING THE MUTEX */ __po_hi_mutex_unlock (&__po_hi_c_trace_mutex); return __PO_HI_SUCCESS;