Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
229b15bf6894029f3d18dd967fc4c9c1bfb0006a
[simgrid.git] / src / instr / smx_instr.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "instr/private.h"
8
9 #ifdef HAVE_TRACING
10
11 static long long int counter = 0; /* to uniquely identify simix actions */
12
13 void TRACE_smx_action_execute (smx_action_t act)
14 {
15         char *category = NULL;
16   if (!IS_TRACING) return;
17
18   act->counter = counter++;
19   category = __TRACE_category_get (SIMIX_process_self());
20   if (category){
21     act->category = xbt_new (char, strlen (category)+1);
22     strncpy (act->category, category, strlen(category)+1);
23   }
24   __TRACE_surf_resource_utilization_start (act);
25 }
26
27 void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
28 {
29         char *category = NULL;
30   if (!IS_TRACING) return;
31
32   act->counter = counter++;
33   category = __TRACE_category_get (proc);
34   if (category){
35     act->category = xbt_strdup (category);
36   }
37   __TRACE_surf_resource_utilization_start (act);
38 }
39
40 void TRACE_smx_action_destroy (smx_action_t act)
41 {
42   if (!IS_TRACING || !IS_TRACED(act)) return;
43
44   if (act->category){
45     xbt_free (act->category);
46   }
47   __TRACE_surf_resource_utilization_end (act);
48 }
49
50 #endif