3 /* time - time related syscal wrappers */
5 /* Copyright (c) 2003-2007 Martin Quinson. All rights reserved. */
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. */
10 #include "gras/Virtu/virtu_sg.h"
13 * Time elapsed since the begining of the simulation.
17 return SIMIX_get_clock();
21 * Freeze the process for the specified amount of time
23 void xbt_sleep(double sec)
25 smx_action_t act_sleep;
26 smx_process_t proc = SIMIX_process_self();
29 /* create action to sleep */
30 act_sleep = SIMIX_action_sleep(SIMIX_process_get_host(proc), sec);
32 mutex = SIMIX_mutex_init();
33 SIMIX_mutex_lock(mutex);
34 /* create conditional and register action to it */
35 cond = SIMIX_cond_init();
37 SIMIX_register_action_to_condition(act_sleep, cond);
38 SIMIX_cond_wait(cond, mutex);
39 SIMIX_mutex_unlock(mutex);
41 /* remove variables */
42 SIMIX_cond_destroy(cond);
43 SIMIX_mutex_destroy(mutex);
44 SIMIX_action_destroy(act_sleep);