summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b4da4ac)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1050
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
/* 8. Sleep one second, but only in real life, not in simulation */
if (!gras_if_RL())
/* 8. Sleep one second, but only in real life, not in simulation */
if (!gras_if_RL())
/* 9. Free the allocated resources, and shut GRAS down */
gras_socket_close(globals->sock);
/* 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 */
INFO2("Launch client (server on %s:%d)",host,port);
/* 3. Wait for the server startup */
/* 4. Create a socket to speak to the server */
if ((errcode=gras_socket_client(host,port,&toserver))) {
/* 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
/** @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
*
/** @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. */
/* 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"
#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
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);
- if (usec/1000000) sleep(usec/1000000);
- (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 */
}
#endif /* ! HAVE_USLEEP */
}
/*
* Freeze the process for the specified amount of time
*/
/*
* 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);