[Spread-cvs] commit: r415 - branches/events_testing/daemon

jschultz at spread.org jschultz at spread.org
Sun May 17 14:45:47 EDT 2009


Author: jschultz
Date: 2009-05-17 14:45:47 -0400 (Sun, 17 May 2009)
New Revision: 415

Modified:
   branches/events_testing/daemon/events.c
   branches/events_testing/daemon/events.old.c
   branches/events_testing/daemon/microbench_events_pipes.c
Log:
Added some code to make test program simulate Spread's usage.  Fixed a bug in the priorities registration for select. 
Added some calls to old events so the test program works with both old and new w/o conditional compilation.


Modified: branches/events_testing/daemon/events.c
===================================================================
--- branches/events_testing/daemon/events.c	2009-05-17 06:08:51 UTC (rev 414)
+++ branches/events_testing/daemon/events.c	2009-05-17 18:45:47 UTC (rev 415)
@@ -1,6 +1,6 @@
 #include "arch.h"
 
-#define HAVE_LINUX
+/*#define HAVE_LINUX*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -607,7 +607,9 @@
 
       for (starve_lvl = events->max_priority; starve_lvl >= events->active_threshold; --starve_lvl) {
 
-        if (starve_lvl != dispatch_lvl && events->priorities[starve_lvl].starve_thresh != 0) {
+        if (starve_lvl != dispatch_lvl && 
+	    events->priorities[starve_lvl].starve_thresh != 0 &&
+	    events->priorities[starve_lvl].num_active_fd_watches != 0) {
           ++events->priorities[starve_lvl].starve_cnter;
         }
       }
@@ -1582,11 +1584,11 @@
   assert(fd_watch->w.watch_type >= 0 && fd_watch->w.watch_type <= NUM_FDTYPES);
   assert(!fd_watch->active);
 
-  /* go down to the watch's priority lvl adding the new watch to each priority's fd sets */
+  /* add the new watch to each priority's fd sets up to its priority lvl */
 
-  for (lvl = events->max_priority; lvl >= fd_watch->w.priority; --lvl) {
+  for (lvl = E_MIN_PRIORITY; lvl <= fd_watch->w.priority; ++lvl) {
 
-    lvl_info = (E_select_lvl_info*) events->priorities[fd_watch->w.priority].backend_lvl_info;
+    lvl_info = (E_select_lvl_info*) events->priorities[lvl].backend_lvl_info;
 
     assert(!FD_ISSET(fd_watch->fd, &lvl_info->fd_sets[fd_watch->w.watch_type]));
     assert(!stdskl_contains(&lvl_info->fd_skls[fd_watch->w.watch_type], &fd_watch->fd));
@@ -1635,11 +1637,11 @@
      our logic must be conditional within the loop.
   */
 
-  /* go down to the watch's priority lvl adding the new watch to each priority's fd sets */
+  /* remove the watch from each priority's fd sets up to its priority lvl */
 
-  for (lvl = events->max_priority; lvl >= fd_watch->w.priority; --lvl) {
+  for (lvl = E_MIN_PRIORITY; lvl <= fd_watch->w.priority; ++lvl) {
 
-    lvl_info = (E_select_lvl_info*) events->priorities[fd_watch->w.priority].backend_lvl_info;
+    lvl_info = (E_select_lvl_info*) events->priorities[lvl].backend_lvl_info;
 
     if (FD_ISSET(fd_watch->fd, &lvl_info->fd_sets[fd_watch->w.watch_type])) {
 

Modified: branches/events_testing/daemon/events.old.c
===================================================================
--- branches/events_testing/daemon/events.old.c	2009-05-17 06:08:51 UTC (rev 414)
+++ branches/events_testing/daemon/events.old.c	2009-05-17 18:45:47 UTC (rev 415)
@@ -94,6 +94,12 @@
 static	int		Active_priority;
 static	int		Exit_events;
 
+sp_time E_get_loop_time( void ) { return E_get_time(); }
+sp_time E_update_loop_time( void ) { return E_get_time(); }
+
+int     E_set_elevate_count( int priority, unsigned count ) { return 0; }
+int     E_get_elevate_count( int priority, unsigned *count ) { return 0; }
+
 int 	E_init(void)
 {
 	int	i,ret;

Modified: branches/events_testing/daemon/microbench_events_pipes.c
===================================================================
--- branches/events_testing/daemon/microbench_events_pipes.c	2009-05-17 06:08:51 UTC (rev 414)
+++ branches/events_testing/daemon/microbench_events_pipes.c	2009-05-17 18:45:47 UTC (rev 415)
@@ -105,7 +105,16 @@
   assert(Num_Ops_Cmplt < Num_Ops_Done && Num_Ops_Done <= Num_Ops);
 
   if (Num_Ops_Done != Num_Ops) {
-    write_pipe(get_rand_pipe());
+
+    if ((Num_Ops_Done & 0x1) == 0) {
+      write_pipe(0);                /* keep "data" fd very busy */
+
+    } else if ((Num_Ops_Done & 0x3f) == 0) {
+      write_pipe(1);                /* keep "token" fd somewhat busy */
+
+    } else {
+      write_pipe(get_rand_pipe());  /* keep "client" fds rarely busy */
+    }
   }
 
   ++Num_Ops_Cmplt;
@@ -193,17 +202,44 @@
       perror("ioctl failed"), abort();
     }
 
-    E_attach_fd(Pipes[i][0], READ_FD, read_pipe, 0, NULL, HIGH_PRIORITY);
+    switch (i) {
+
+    case 0:
+      E_attach_fd(Pipes[i][0], READ_FD, read_pipe, 0, NULL, HIGH_PRIORITY);
+      break;
+
+    case 1:
+      E_attach_fd(Pipes[i][0], READ_FD, read_pipe, 0, NULL, MEDIUM_PRIORITY);
+      break;
+
+    default:
+      E_attach_fd(Pipes[i][0], READ_FD, read_pipe, 0, NULL, LOW_PRIORITY /*(int) (NUM_FDTYPES * (rand() / (RAND_MAX + 1.0)))*/ );
+      break;
+    }
   }
 
-  /* seed the system */
+  /* seed the system with activity */
 
   for (i = 0; i != Num_Pending && i != Num_Ops; ++i) {
-    write_pipe(get_rand_pipe());
+
+    switch (i) {
+
+    case 0:
+    case 1:
+      write_pipe(i);
+      break;
+
+    default:
+      write_pipe(get_rand_pipe());
+      break;
+    }
   }
 
   /* loop handling events */
 
+  E_set_elevate_count(HIGH_PRIORITY, 1);
+  E_set_elevate_count(LOW_PRIORITY, 5);
+
   T1 = E_get_time();
 
   ret = E_handle_events();




More information about the Spread-cvs mailing list