From: mquinson Date: Thu, 22 Jul 2004 03:12:33 +0000 (+0000) Subject: Move Virtu functions into the gras_os_ namespace X-Git-Tag: v3.3~5044 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7f7f3561941c2be9d43711afb3036dc47df26651 Move Virtu functions into the gras_os_ namespace git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@304 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/TODO b/TODO index 10c40b00cd..4ee5c6f14f 100644 --- a/TODO +++ b/TODO @@ -11,10 +11,7 @@ ### Avant 1.0 ### -- renomages - gras_os_time - gras_os_sleep - gras_os_getload +- gras_os_getload - gras_datadesc_import_nws diff --git a/include/virtu.h b/include/virtu.h index 2466a33592..a57ccdb442 100644 --- a/include/virtu.h +++ b/include/virtu.h @@ -38,21 +38,21 @@ BEGIN_DECL /** - * gras_time: + * gras_os_time: * * Get the time in number of second since the Epoch. * (00:00:00 UTC, January 1, 1970 in Real Life, and begining of simulation in SG) */ -double gras_time(void); +double gras_os_time(void); /** - * gras_sleep: + * gras_os_sleep: * @sec: number of seconds to sleep * @usec: number of microseconds to sleep * * sleeps for the given amount of seconds plus the given amount of microseconds. */ -void gras_sleep(unsigned long sec, unsigned long usec); +void gras_os_sleep(unsigned long sec, unsigned long usec); END_DECL diff --git a/src/gras/Msg/msg.c b/src/gras/Msg/msg.c index ec5831d225..91d5aca0fa 100644 --- a/src/gras/Msg/msg.c +++ b/src/gras/Msg/msg.c @@ -91,9 +91,8 @@ static char *make_namev(const char *name, short int ver) { */ gras_error_t gras_msgtype_declare(const char *name, - gras_datadesc_type_t *payload, - gras_msgtype_t **dst) { - return gras_msgtype_declare_v(name, 0, payload, dst); + gras_datadesc_type_t *payload) { + return gras_msgtype_declare_v(name, 0, payload); } /** @@ -111,8 +110,7 @@ gras_msgtype_declare(const char *name, gras_error_t gras_msgtype_declare_v(const char *name, short int version, - gras_datadesc_type_t *payload, - gras_msgtype_t **dst) { + gras_datadesc_type_t *payload) { gras_error_t errcode; gras_msgtype_t *msgtype; @@ -151,7 +149,7 @@ gras_msgtype_declare_v(const char *name, TRY(gras_set_add(_gras_msgtype_set, (gras_set_elm_t*)msgtype, &gras_msgtype_free)); - + return no_error; } @@ -293,7 +291,7 @@ gras_msg_wait(double timeout, VERB1("Waiting for message %s",msgt_want->name); - start = now = gras_time(); + start = now = gras_os_time(); gras_dynar_foreach(pd->msg_queue,cpt,msg){ if (msg.type->code == msgt_want->code) { @@ -323,7 +321,7 @@ gras_msg_wait(double timeout, msg.payload_size = payload_size_got; TRY(gras_dynar_push(pd->msg_queue,&msg)); - now=gras_time(); + now=gras_os_time(); if (now - start + 0.001 < timeout) { RAISE1(timeout_error,"Timeout while waiting for msg %s",msgt_want->name); } diff --git a/src/gras/Transport/rl_transport.c b/src/gras/Transport/rl_transport.c index 858ba73186..1dfa236d50 100644 --- a/src/gras/Transport/rl_transport.c +++ b/src/gras/Transport/rl_transport.c @@ -36,7 +36,7 @@ gras_trp_select(double timeout, gras_error_t errcode; gras_dynar_t *sockets= gras_socketset_get(); int done = -1; - double wakeup = gras_time() + 1000000*timeout; + double wakeup = gras_os_time() + 1000000*timeout; double now = 0; /* nextToService used to make sure socket with high number do not starve */ // static int nextToService = 0; @@ -52,7 +52,7 @@ gras_trp_select(double timeout, *dst=NULL; while (done == -1) { if (timeout > 0) { /* did we timeout already? */ - now = gras_time(); + now = gras_os_time(); if (now == -1 || now >= wakeup) { done = 0; /* didn't find anything */ break; diff --git a/src/gras/Transport/sg_transport.c b/src/gras/Transport/sg_transport.c index b17f5fc27c..80bf996142 100644 --- a/src/gras/Transport/sg_transport.c +++ b/src/gras/Transport/sg_transport.c @@ -31,7 +31,7 @@ gras_trp_select(double timeout, gras_socket_t **dst) { gras_error_t errcode; - double startTime=gras_time(); + double startTime=gras_os_time(); gras_procdata_t *pd=gras_procdata_get(); gras_trp_sg_sock_data_t *sockdata; gras_trp_plugin_t *trp; @@ -138,7 +138,7 @@ gras_trp_select(double timeout, // MSG_process_sleep(1); MSG_process_sleep(0.01); } - } while (gras_time()-startTime < timeout + } while (gras_os_time()-startTime < timeout || MSG_task_Iprobe((m_channel_t) pd->chan)); return timeout_error; diff --git a/src/gras/Virtu/rl_time.c b/src/gras/Virtu/rl_time.c index c65d26157c..f9d80742fa 100644 --- a/src/gras/Virtu/rl_time.c +++ b/src/gras/Virtu/rl_time.c @@ -11,7 +11,7 @@ #include "gras_private.h" #include /* gettimeofday() */ -double gras_time() { +double gras_os_time() { struct timeval tv; gettimeofday(&tv, NULL); @@ -19,7 +19,7 @@ double gras_time() { return (double)(tv.tv_sec * 1000000 + tv.tv_usec); } -void gras_sleep(unsigned long sec,unsigned long usec) { +void gras_os_sleep(unsigned long sec,unsigned long usec) { sleep(sec); if (usec/1000000) sleep(usec/1000000); diff --git a/src/gras/Virtu/sg_time.c b/src/gras/Virtu/sg_time.c index 1f50a85d1c..f71c8b3e47 100644 --- a/src/gras/Virtu/sg_time.c +++ b/src/gras/Virtu/sg_time.c @@ -10,10 +10,23 @@ #include "Virtu/virtu_sg.h" -double gras_time() { +/** + * gras_time: + * @Returns: The current time + * + * The epoch since when the time is given is not specified. It is thus only usefull to compute intervals + */ +double gras_os_time() { return MSG_getClock(); } - -void gras_sleep(unsigned long sec,unsigned long usec) { + +/** + * gras_sleep: + * @sec: amount of sec to sleep + * @usec: amount of micro second to sleep + * + * Freeze the process for the specified amount of time + */ +void gras_os_sleep(unsigned long sec,unsigned long usec) { MSG_process_sleep((double)sec + ((double)usec)/1000000); }