Change polling granularity from seconds to milliseconds

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Change polling granularity from seconds to milliseconds

Kevin Buettner
I've just committed the patch below.  It improves RDA's response time
when debugging certain types of multithreaded applications.

Kevin

ChangeLog:
        * include/gdbloop.h (gdbloop, gdbloop_poll): Revise comments
        to indicate that timeout granulatiry is now in milliseconds
        rather than seconds.
        * lib/gdbloop.c (poll_gdbsocket): Change ``timeout'' granulatiry
        from seconds to milliseconds.

unix/ChangeLog:
        * server.c (main): Change polling interval for gdbloop_poll()
        from one second to ten milliseconds.

win32/ChangeLog:
        * server.c (main): Revise comment to indicate that polling
        granularity is milliseconds.

Index: include/gdbloop.h
===================================================================
RCS file: /cvs/src/src/rda/include/gdbloop.h,v
retrieving revision 1.1
diff -u -p -r1.1 gdbloop.h
--- include/gdbloop.h 28 Aug 2002 01:22:27 -0000 1.1
+++ include/gdbloop.h 16 Mar 2006 22:52:30 -0000
@@ -34,13 +34,17 @@ extern "C" {
 
 /* Really simple minded event-loop.  Assumes that the target is using
    both gdbsocket* and gdbsched* to implement things. If TIMEOUT is
-   negative, block infinitely.  If TIMEOUT is zero, don't block.  */
+   negative, block infinitely.  If TIMEOUT is zero, don't block.
+   Otherwise, a positive timeout represents the time in milliseconds
+   to wait.  */
 
 void gdbloop (long current_time, int timeout);
 
-/* Even more simple minded event-loop.  Assumes that everything is in
-   units of one second.  Calls gdbloop() above, using time() for
-   CURRENT_TIME.  */
+/* An even more simple minded event-loop.  Calls gdbloop()
+   above, using time() for CURRENT_TIME.  TIMEOUT is as above
+   in which a negative TIMEOUT will block indefinitely, a zero
+   timeout won't block at all, and a positive TIMEOUT will
+   block for (at most) the specified number of milliseconds.  */
 
 void gdbloop_poll (int timeout);
 
Index: lib/gdbloop.c
===================================================================
RCS file: /cvs/src/src/rda/lib/gdbloop.c,v
retrieving revision 1.1
diff -u -p -r1.1 gdbloop.c
--- lib/gdbloop.c 28 Aug 2002 01:22:28 -0000 1.1
+++ lib/gdbloop.c 16 Mar 2006 22:52:30 -0000
@@ -86,7 +86,7 @@ fds_isset (int fd, void *context, enum g
 }
 
 static void
-poll_gdbsocket (long timeout)
+poll_gdbsocket (long timeout /* in milliseconds */)
 {
   int s;
   struct fds fds;
@@ -103,8 +103,8 @@ poll_gdbsocket (long timeout)
   if (timeout >= 0)
     {
       struct timeval timeval;
-      timeval.tv_sec = timeout;
-      timeval.tv_usec = 0;
+      timeval.tv_sec = timeout / 1000;
+      timeval.tv_usec = (timeout % 1000) * 1000;
       s = select (fds.nr, &fds.read, &fds.write, NULL, &timeval);
     }
   else
Index: unix/server.c
===================================================================
RCS file: /cvs/src/src/rda/unix/server.c,v
retrieving revision 1.10
diff -u -p -r1.10 server.c
--- unix/server.c 10 Mar 2005 23:50:47 -0000 1.10
+++ unix/server.c 16 Mar 2006 22:52:30 -0000
@@ -413,7 +413,7 @@ main (int argc, char **argv)
   /* Poll for socket traffic. */
   while (! server_quit_p)
     {
-      gdbloop_poll (1 /* second */);
+      gdbloop_poll (10 /* milliseconds */);
       if (! server_quit_p)
  {
   if (gdbserver.check_child_state (process))
Index: win32/server.cc
===================================================================
RCS file: /cvs/src/src/rda/win32/server.cc,v
retrieving revision 1.1
diff -u -p -r1.1 server.cc
--- win32/server.cc 28 Aug 2002 01:22:29 -0000 1.1
+++ win32/server.cc 16 Mar 2006 22:52:30 -0000
@@ -120,7 +120,7 @@ main (int argc, char **argv)
   /* Poll for socket traffic. */
   while (! process->quit_server ())
     {
-      gdbloop_poll (0 /* second */);
+      gdbloop_poll (0 /* milliseconds */);
       if (process->check_state ())
  {
   switch (process->status ())