Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Visual C++ already declare the isatty function in io.h. So this change avoids a warni...
[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   return SIMIX_get_clock();
17 }
18
19 /*
20  * Freeze the process for the specified amount of time
21  */
22 void xbt_sleep(double sec) {
23         smx_action_t act_sleep;
24         smx_process_t proc = SIMIX_process_self();
25         smx_mutex_t mutex;
26         smx_cond_t cond;
27         /* create action to sleep */
28         act_sleep = SIMIX_action_sleep(SIMIX_process_get_host(proc),sec);
29         
30         mutex = SIMIX_mutex_init();
31         SIMIX_mutex_lock(mutex);
32         /* create conditional and register action to it */
33         cond = SIMIX_cond_init();
34
35         SIMIX_register_action_to_condition(act_sleep, cond);
36         SIMIX_cond_wait(cond,mutex);
37         SIMIX_mutex_unlock(mutex);
38
39         /* remove variables */
40         SIMIX_cond_destroy(cond);
41         SIMIX_mutex_destroy(mutex);
42         SIMIX_action_destroy(act_sleep);
43
44 }