rude-patch 9.22 KB
Newer Older
1
2
3
4
5
6
7
8
Index: configure
===================================================================
RCS file: /flux/CVS/emulab-rude/configure,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** configure	27 Jun 2006 17:50:14 -0000	1.1.1.1
--- configure	27 Jun 2006 18:26:14 -0000	1.2
9
***************
10
*** 2062,2068 ****
11
12
13
14
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I../include"
15
16
17
18
  trap '' 1 2 15
  cat > confcache <<\EOF
  # This file is a shell script that caches the results of configure
--- 2062,2068 ----
19
20
21
22
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I\$(srcdir)/../include -I../include"
23
24
25
26
27
28
29
30
31
  trap '' 1 2 15
  cat > confcache <<\EOF
  # This file is a shell script that caches the results of configure
Index: autoconf/configure.in
===================================================================
RCS file: /flux/CVS/emulab-rude/autoconf/configure.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
32
***************
33
*** 121,126 ****
34
35
36
37
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I../include"
38
39
40
  AC_OUTPUT(Makefile:autoconf/Makefile.in rude/Makefile crude/Makefile, \
  	  echo timestamp > include/stamp.h)
--- 121,126 ----
41
42
43
44
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I\$(srcdir)/../include -I../include"
45
46
47
48
49
50
51
52
53
54
  AC_OUTPUT(Makefile:autoconf/Makefile.in rude/Makefile crude/Makefile, \
  	  echo timestamp > include/stamp.h)
Index: crude/main.c
===================================================================
RCS file: /flux/CVS/emulab-rude/crude/main.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** crude/main.c	27 Jun 2006 17:50:15 -0000	1.1.1.1
--- crude/main.c	27 Jun 2006 18:22:10 -0000	1.2
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
***************
*** 294,302 ****
--- 294,306 ----
     */
    if((user_id == 0) && (priority > 0)){
      /* Try to lock the memory to avoid paging delays */
+ #ifdef HAVE_MUNLOCKALL
      if(mlockall(MCL_CURRENT | MCL_FUTURE) < 0){
        RUDEBUG1("crude: memory lock failed: %s\n", strerror(errno));
      }
+ #else
+     RUDEBUG1("crude: memory lock unsupported\n");
+ #endif
  
      /* Switch to Round-Robin-Real-Time Scheduling */
      p.sched_priority = priority;
***************
*** 346,353 ****
--- 350,359 ----
        RUDEBUG7("crude: program priority restored\n");
      }
  
+ #ifdef HAVE_MUNLOCKALL
      /* Release the locked memory */
      munlockall();
+ #endif
    }                                                                             
  
    if(ps_flag){ print_stats(); }
***************
*** 663,670 ****
  
      /* print average delay as sign and absolute value */
      if ( (sec < 0) || (usec < 0) ) {
!       sec  = llabs( sec );
!       usec = llabs( usec );
        printf("Delay: average = -%lld.%06llu   ", sec, usec);
      } else {
        printf("Delay: average = %lld.%06llu   ", sec, usec);
--- 669,676 ----
  
      /* print average delay as sign and absolute value */
      if ( (sec < 0) || (usec < 0) ) {
!       if (sec < 0) sec *= -1;
!       if (usec < 0) usec *= -1;
        printf("Delay: average = -%lld.%06llu   ", sec, usec);
      } else {
        printf("Delay: average = %lld.%06llu   ", sec, usec);
103
104
105
106
107
108
109
110
Index: include/rude.h
===================================================================
RCS file: /flux/CVS/emulab-rude/include/rude.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** include/rude.h	27 Jun 2006 17:50:15 -0000	1.1.1.1
--- include/rude.h	27 Jun 2006 18:22:18 -0000	1.2
111
112
113
114
115
116
117
118
119
120
***************
*** 24,29 ****
--- 24,30 ----
  #ifndef _RUDE_H
  #define _RUDE_H
  
+ #include <sys/types.h>
  #include <netinet/in.h>  /* for struct sockaddr_in */
  #include <sys/time.h>    /* for struct timeval     */
  
121
122
123
124
125
126
127
128
Index: rude/flow_txmit.c
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/flow_txmit.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -c -r1.1.1.1 -r1.3
*** rude/flow_txmit.c	27 Jun 2006 17:50:14 -0000	1.1.1.1
--- rude/flow_txmit.c	27 Jun 2006 18:28:48 -0000	1.3
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
***************
*** 43,58 ****
  extern struct udp_data *data;
  extern char            *buffer;
  
  
  /*
!  * wait_for_xmit(): Wait for certain period of time in busy-loop
   */
  __inline__ void wait_for_xmit(struct timeval *target, struct timeval *now)
  {
    while(1){
-     gettimeofday(now,NULL);
      if(timercmp(now,target,<)){
!       /* FIXME: check if the timegap is large => use [u | nano]sleep() */
        continue;
      }
      return;
--- 43,117 ----
  extern struct udp_data *data;
  extern char            *buffer;
  
+ static int usecpertick = 0;
  
  /*
!  * init_wait(): set the resolution of the clock.
!  * We use this in wait_for_xmit(), if the desired sleep time is at least
!  * twice the clock resolution, we sleep rather than spin.
!  * XXX this could be determined dynamically.
!  */
! void wait_init(int tickspersec)
! {
!   if (tickspersec < 1000000)
!     usecpertick = 1000000 / tickspersec;
! }
! 
! #ifdef WAITSTATS
! static unsigned int calls;
! static unsigned int toolong;
! static unsigned long long toolongby;
! #endif
! 
! void wait_finish(void)
! {
! #ifdef WAITSTATS
!   printf("%d calls, %d slept too long (by %dusec ave)\n",
! 	 calls, toolong, toolongby/toolong);
! #endif
! }
! 
! /*
!  * wait_for_xmit(): Wait for certain period of time
   */
  __inline__ void wait_for_xmit(struct timeval *target, struct timeval *now)
  {
+   gettimeofday(now,NULL);
+   if (usecpertick) {
+     struct timeval dtv;
+     int usec;
+ 
+     timersub(target,now,&dtv);
+     usec = dtv.tv_sec * 1000000 + dtv.tv_usec;
+     if (usec >= usecpertick*2) {
+       int res = usec % usecpertick;
+ 
+       /* empirical voodoo */
+       if (res == 0) res = 1;
+ 
+       usec -= res;
+       dtv.tv_sec = usec / 1000000;
+       dtv.tv_usec = usec % 1000000;
+       select(0,NULL,NULL,NULL,&dtv);
+       gettimeofday(now,NULL);
+ 
+ #ifdef WAITSTATS
+       /* XXX fernow stats */
+       calls++;
+       if (timercmp(now,target,>)) {
+         toolong++;
+         timersub(now,target,&dtv);
+         usec = dtv.tv_sec * 1000000 + dtv.tv_usec;
+         toolongby += usec;
+         return;
+       }
+ #endif
+     }
+   }
+ 
    while(1){
      if(timercmp(now,target,<)){
!       gettimeofday(now,NULL);
        continue;
      }
      return;
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
***************
*** 78,83 ****
--- 137,146 ----
    data->sequence_number = htonl(flow->sequence_nmbr);
    wait_for_xmit(&flow->next_tx, &now);
  
+   /* Emulab hack: this can happen for a final zero transmission */
+   if (p->rate == 0)
+     return;
+ 
    /* ...and fill in the rest of the data */
    data->tx_time_seconds  = htonl(now.tv_sec);
    data->tx_time_useconds = htonl(now.tv_usec);
Index: rude/main.c
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/main.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** rude/main.c	27 Jun 2006 17:50:14 -0000	1.1.1.1
--- rude/main.c	27 Jun 2006 18:22:23 -0000	1.2
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
***************
*** 95,101 ****
      exit(1);
    }
  
!   while(((opt_ret=getopt(argc,argv,"s:P:hv")) != EOF) && (retval == 0)){
      switch(opt_ret){
      case 'v':
        if((optind == 2) && (argc == 2)){
--- 95,101 ----
      exit(1);
    }
  
!   while(((opt_ret=getopt(argc,argv,"s:P:hvC:")) != EOF) && (retval == 0)){
      switch(opt_ret){
      case 'v':
        if((optind == 2) && (argc == 2)){
***************
*** 147,152 ****
--- 147,156 ----
        }
        break;
  
+     case 'C':
+       wait_init(atoi(optarg));
+       break;
+ 
      default:
        usage(argv[0]);
        retval = -2;
***************
*** 204,212 ****
--- 208,220 ----
     */
    if((user_id == 0) && (priority > 0)){
      /* Try to lock the memory to avoid paging delays */
+ #ifdef HAVE_MUNLOCKALL
      if(mlockall(MCL_CURRENT | MCL_FUTURE) < 0){
        RUDEBUG1("rude: memory lock failed: %s\n", strerror(errno));
      }
+ #else
+     RUDEBUG1("rude: memory lock unsupported\n");
+ #endif
  
      /* Switch to Round-Robin-Real-Time Scheduling */
      p.sched_priority = priority;
***************
*** 242,249 ****
--- 250,259 ----
        RUDEBUG7("rude: program priority restored\n");
      }
  
+ #ifdef HAVE_MUNLOCKALL
      /* Release the locked memory */
      munlockall();
+ #endif
    }
  
   rude_exit1:
***************
*** 275,281 ****
--- 285,293 ----
      }
    }
  
+ #ifdef HAVE_MUNLOCKALL
    munlockall();
+ #endif
    clean_up();
    exit(ret_val);
  } /* main() */
***************
*** 414,419 ****
--- 426,432 ----
      }
      flow = flow->next;
    }
+   wait_finish();
    return;
  } /* print_results() */
  
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
Index: rude/parse.c
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/parse.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** rude/parse.c	27 Jun 2006 17:50:14 -0000	1.1.1.1
--- rude/parse.c	27 Jun 2006 18:28:48 -0000	1.2
***************
*** 688,694 ****
--- 688,696 ----
        /* NEW in 0.50: Enable flow "stop" - ZERO transmission rate... */
        if(temp->params.cbr.rate == 0){
  	temp->next_tx = temp->flow_stop;
+ 	/* Emulab hack: make final zero transmission actually happen
  	temp->next_tx.tv_sec++;
+ 	*/
        }
        break;
      case(TRACE):