A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
461406a
)
Replace usleep for nanosleep
author
navarro
<navarro@caraja.(none)>
Wed, 20 Jun 2012 12:12:43 +0000
(14:12 +0200)
committer
navarro
<navarro@caraja.(none)>
Wed, 20 Jun 2012 12:14:32 +0000
(14:14 +0200)
buildtools/Cmake/CompleteInFiles.cmake
patch
|
blob
|
history
buildtools/Cmake/PrintArgs.cmake
patch
|
blob
|
history
buildtools/Cmake/src/gras_config.h.in
patch
|
blob
|
history
src/win32/compiler/borland.h
patch
|
blob
|
history
src/win32/compiler/visualc.h
patch
|
blob
|
history
src/xbt/xbt_os_time.c
patch
|
blob
|
history
tools/tesh/run_context.c
patch
|
blob
|
history
diff --git
a/buildtools/Cmake/CompleteInFiles.cmake
b/buildtools/Cmake/CompleteInFiles.cmake
index
5a0bf0c
..
bf896dd
100644
(file)
--- a/
buildtools/Cmake/CompleteInFiles.cmake
+++ b/
buildtools/Cmake/CompleteInFiles.cmake
@@
-131,7
+131,7
@@
CHECK_INCLUDE_FILE("stdio.h" HAVE_STDIO_H)
CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
-CHECK_FUNCTION_EXISTS(
usleep HAVE_U
SLEEP)
+CHECK_FUNCTION_EXISTS(
nanosleep HAVE_NANO
SLEEP)
CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
CHECK_FUNCTION_EXISTS(readv HAVE_READV)
CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
CHECK_FUNCTION_EXISTS(readv HAVE_READV)
diff --git
a/buildtools/Cmake/PrintArgs.cmake
b/buildtools/Cmake/PrintArgs.cmake
index
1e06c85
..
8518ffe
100644
(file)
--- a/
buildtools/Cmake/PrintArgs.cmake
+++ b/
buildtools/Cmake/PrintArgs.cmake
@@
-54,7
+54,7
@@
if(enable_print_message)
message("")
message("HAVE_GETTIMEOFDAY ...........: ${HAVE_GETTIMEOFDAY}")
message("")
message("HAVE_GETTIMEOFDAY ...........: ${HAVE_GETTIMEOFDAY}")
- message("HAVE_
USLEEP .................: ${HAVE_U
SLEEP}")
+ message("HAVE_
NANOSLEEP ..............: ${HAVE_NANO
SLEEP}")
message("HAVE_GETDTABLESIZE ..........: ${HAVE_GETDTABLESIZE}")
message("HAVE_SYSCONF ................: ${HAVE_SYSCONF}")
message("HAVE_READV ..................: ${HAVE_READV}")
message("HAVE_GETDTABLESIZE ..........: ${HAVE_GETDTABLESIZE}")
message("HAVE_SYSCONF ................: ${HAVE_SYSCONF}")
message("HAVE_READV ..................: ${HAVE_READV}")
diff --git
a/buildtools/Cmake/src/gras_config.h.in
b/buildtools/Cmake/src/gras_config.h.in
index
e637923
..
7aa25e2
100644
(file)
--- a/
buildtools/Cmake/src/gras_config.h.in
+++ b/
buildtools/Cmake/src/gras_config.h.in
@@
-232,8
+232,8
@@
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
-/* Define to 1 if you have the `
u
sleep' function. */
-#cmakedefine HAVE_
USLEEP @HAVE_U
SLEEP@
+/* Define to 1 if you have the `
nano
sleep' function. */
+#cmakedefine HAVE_
NANOSLEEP @HAVE_NANO
SLEEP@
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
#cmakedefine HAVE_VALGRIND_VALGRIND_H @HAVE_VALGRIND_VALGRIND_H@
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
#cmakedefine HAVE_VALGRIND_VALGRIND_H @HAVE_VALGRIND_VALGRIND_H@
diff --git
a/src/win32/compiler/borland.h
b/src/win32/compiler/borland.h
index
50d9f02
..
d58c6dc
100644
(file)
--- a/
src/win32/compiler/borland.h
+++ b/
src/win32/compiler/borland.h
@@
-180,9
+180,9
@@
#undef HAVE_SYSCONF
#endif
#undef HAVE_SYSCONF
#endif
-/* No `
u
sleep' function. */
-#if defined(HAVE_
U
SLEEP)
-#undef HAVE_
U
SLEEP
+/* No `
nano
sleep' function. */
+#if defined(HAVE_
NANO
SLEEP)
+#undef HAVE_
NANO
SLEEP
#endif
/* The compiler has the `vsnprintf' function. */
#endif
/* The compiler has the `vsnprintf' function. */
diff --git
a/src/win32/compiler/visualc.h
b/src/win32/compiler/visualc.h
index
2f22ad4
..
927349e
100644
(file)
--- a/
src/win32/compiler/visualc.h
+++ b/
src/win32/compiler/visualc.h
@@
-188,9
+188,9
@@
#undef HAVE_SYSCONF
#endif
#undef HAVE_SYSCONF
#endif
-/* No `
u
sleep' function. */
-#if defined(HAVE_
U
SLEEP)
-#undef HAVE_
U
SLEEP
+/* No `
nano
sleep' function. */
+#if defined(HAVE_
NANO
SLEEP)
+#undef HAVE_
NANO
SLEEP
#endif
/* The compiler has the `vsnprintf' function. */
#endif
/* The compiler has the `vsnprintf' function. */
diff --git
a/src/xbt/xbt_os_time.c
b/src/xbt/xbt_os_time.c
index
7b54af1
..
dc72c91
100644
(file)
--- a/
src/xbt/xbt_os_time.c
+++ b/
src/xbt/xbt_os_time.c
@@
-59,14
+59,14
@@
void xbt_os_sleep(double sec)
#ifdef _XBT_WIN32
Sleep((floor(sec) * 1000) + ((sec - floor(sec)) * 1000));
#ifdef _XBT_WIN32
Sleep((floor(sec) * 1000) + ((sec - floor(sec)) * 1000));
-#elif HAVE_USLEEP
- sleep(sec);
- (void) usleep((sec - floor(sec)) * 1000000);
-
-#else /* don't have usleep. Use select to sleep less than one second */
+#elif HAVE_NANOSLEEP
+ struct timespec ts;
+ ts.tv_sec = sec;
+ ts.tv_nsec = (sec - floor(sec)) * 1e9;
+ nanosleep (&ts, NULL);
+#else /* don't have nanosleep. Use select to sleep less than one second */
struct timeval timeout;
struct timeval timeout;
-
timeout.tv_sec = (unsigned long) (sec);
timeout.tv_usec = (sec - floor(sec)) * 1000000;
timeout.tv_sec = (unsigned long) (sec);
timeout.tv_usec = (sec - floor(sec)) * 1000000;
diff --git
a/tools/tesh/run_context.c
b/tools/tesh/run_context.c
index
756666d
..
ea3ec6e
100644
(file)
--- a/
tools/tesh/run_context.c
+++ b/
tools/tesh/run_context.c
@@
-13,6
+13,7
@@
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <math.h> /* floor */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
@@
-133,7
+134,10
@@
static void rctx_armageddon_kill_one(rctx_t initiator, const char *filepos,
if (!rctx->reader_done) {
rctx->interrupted = 1;
kill(rctx->pid, SIGTERM);
if (!rctx->reader_done) {
rctx->interrupted = 1;
kill(rctx->pid, SIGTERM);
- usleep(100);
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = (100e-6 - floor(100e-6)) * 1e9;
+ nanosleep (&ts, NULL);
kill(rctx->pid, SIGKILL);
}
xbt_os_mutex_release(rctx->interruption);
kill(rctx->pid, SIGKILL);
}
xbt_os_mutex_release(rctx->interruption);
@@
-169,7
+173,10
@@
void rctx_armageddon(rctx_t initiator, int exitcode)
}
/* Give runner threads a chance to acknowledge the processes deaths */
}
/* Give runner threads a chance to acknowledge the processes deaths */
- usleep(10000);
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = (10000e-6 - floor(10000e-6)) * 1e9;
+ nanosleep (&ts, NULL);
/* Ensure that nobody is running rctx_wait on exit */
if (fg_job)
xbt_os_mutex_acquire(rctx->interruption);
/* Ensure that nobody is running rctx_wait on exit */
if (fg_job)
xbt_os_mutex_acquire(rctx->interruption);
@@
-410,8
+417,12
@@
static void *thread_writer(void *r)
}
XBT_DEBUG("written %d chars so far", posw);
}
XBT_DEBUG("written %d chars so far", posw);
- if (got <= 0)
- usleep(100);
+ if (got <= 0){
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = (100e-6 - floor(100e-6)) * 1e9;
+ nanosleep (&ts, NULL);
+ }
}
rctx->input->data[0] = '\0';
rctx->input->used = 0;
}
rctx->input->data[0] = '\0';
rctx->input->used = 0;
@@
-438,7
+449,10
@@
static void *thread_reader(void *r)
buffout[posr] = '\0';
xbt_strbuff_append(rctx->output_got, buffout);
} else {
buffout[posr] = '\0';
xbt_strbuff_append(rctx->output_got, buffout);
} else {
- usleep(100);
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = (100e-6 - floor(100e-6)) * 1e9;
+ nanosleep (&ts, NULL);
}
} while (!rctx->timeout && posr != 0);
free(buffout);
}
} while (!rctx->timeout && posr != 0);
free(buffout);
@@
-697,7
+711,10
@@
void *rctx_wait(void *r)
/* Wait for the child to die or the timeout to happen (or an armageddon to happen) */
while (!rctx->reader_done
&& (rctx->end_time < 0 || rctx->end_time >= now)) {
/* Wait for the child to die or the timeout to happen (or an armageddon to happen) */
while (!rctx->reader_done
&& (rctx->end_time < 0 || rctx->end_time >= now)) {
- usleep(100);
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = (100e-6 - floor(100e-6)) * 1e9;
+ nanosleep (&ts, NULL);
now = time(NULL);
}
now = time(NULL);
}
@@
-706,7
+723,10
@@
void *rctx_wait(void *r)
XBT_INFO("<%s> timeouted. Kill the process.", rctx->filepos);
rctx->timeout = 1;
kill(rctx->pid, SIGTERM);
XBT_INFO("<%s> timeouted. Kill the process.", rctx->filepos);
rctx->timeout = 1;
kill(rctx->pid, SIGTERM);
- usleep(100);
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = (100e-6 - floor(100e-6)) * 1e9;
+ nanosleep (&ts, NULL);
kill(rctx->pid, SIGKILL);
}
kill(rctx->pid, SIGKILL);
}