/* 8. Sleep one second, but only in real life, not in simulation */
if (!gras_if_RL())
- gras_os_sleep(1, 0);
+ gras_os_sleep(1);
/* 9. Free the allocated resources, and shut GRAS down */
gras_socket_close(globals->sock);
INFO2("Launch client (server on %s:%d)",host,port);
/* 3. Wait for the server startup */
- gras_os_sleep(1,0);
+ gras_os_sleep(1);
/* 4. Create a socket to speak to the server */
if ((errcode=gras_socket_client(host,port,&toserver))) {
/** @brief sleeps for the given amount of time.
* @param sec: number of seconds to sleep
- * @param usec: number of microseconds to sleep
*/
-void gras_os_sleep(unsigned long sec, unsigned long usec);
+void gras_os_sleep(double sec);
/** @brief get the fully-qualified name of the current host
*
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "math.h" /* floor */
+
#include "portable.h"
#include "xbt/sysdep.h"
#include "gras/virtu.h"
+XBT_LOG_EXTERNAL_CATEGORY(virtu);
+XBT_LOG_DEFAULT_CATEGORY(virtu);
double gras_os_time() {
#ifdef HAVE_GETTIMEOFDAY
}
-void gras_os_sleep(unsigned long sec,unsigned long usec) {
+void gras_os_sleep(double sec) {
+ DEBUG1("Do sleep %d sec", (int)sec);
sleep(sec);
- if (usec/1000000) sleep(usec/1000000);
#ifdef HAVE_USLEEP
- (void)usleep(usec % 1000000);
+ DEBUG1("Do sleep %d usec", (int) ((sec - floor(sec)) * 1000000 ));
+ (void)usleep( (sec - floor(sec)) * 1000000);
+#else
+ if ( ((int) sec) == 0) {
+ WARN0("This platform does not implement usleep. Cannot sleep less than one second");
+ }
#endif /* ! HAVE_USLEEP */
}
/*
* 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);
+void gras_os_sleep(double sec) {
+ MSG_process_sleep(sec);
}