Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
new tracing mask TRACE_VOLUME to trace the msg tasks communication size and group...
[simgrid.git] / src / xbt / xbt_sg_time.c
1 /* $Id$ */
2
3 /* time - time related syscal wrappers                                      */
4
5 /* Copyright (c) 2003-2007 Martin Quinson.  All rights reserved.            */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include "gras/Virtu/virtu_sg.h"
11
12 /*
13  * Time elapsed since the begining of the simulation.
14  */
15 double xbt_time()
16 {
17   return SIMIX_get_clock();
18 }
19
20 /*
21  * Freeze the process for the specified amount of time
22  */
23 void xbt_sleep(double sec)
24 {
25   smx_action_t act_sleep;
26   smx_process_t proc = SIMIX_process_self();
27   smx_mutex_t mutex;
28   smx_cond_t cond;
29   /* create action to sleep */
30   act_sleep = SIMIX_action_sleep(SIMIX_process_get_host(proc), sec);
31
32   mutex = SIMIX_mutex_init();
33   SIMIX_mutex_lock(mutex);
34   /* create conditional and register action to it */
35   cond = SIMIX_cond_init();
36
37   SIMIX_register_action_to_condition(act_sleep, cond);
38   SIMIX_cond_wait(cond, mutex);
39   SIMIX_mutex_unlock(mutex);
40
41   /* remove variables */
42   SIMIX_cond_destroy(cond);
43   SIMIX_mutex_destroy(mutex);
44   SIMIX_action_destroy(act_sleep);
45
46 }