diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-08-16 17:27:52 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-08-16 17:27:52 +0000 |
commit | 5ee0701a857381ee2b99c4822e65c1cb4f6f513e (patch) | |
tree | 3e9259161177d70f25b67d1a8009b2a3a279f65f | |
parent | 13bcedb4138546f42567509f519e0d6221c1ef22 (diff) |
2007-08-16 Joel Sherrill <joel.sherrill@oarcorp.com>
* init.c: Change clock tick to 1 millisecond.
* rtems_ttcp.c: Add CPU usage reporting.
* ttcp_orig/ttcp.c: Add -m option for delaying between writes.
-rw-r--r-- | ttcp/ChangeLog | 6 | ||||
-rw-r--r-- | ttcp/init.c | 2 | ||||
-rw-r--r-- | ttcp/rtems_ttcp.c | 2 | ||||
-rw-r--r-- | ttcp/ttcp_orig/ttcp.c | 31 |
4 files changed, 38 insertions, 3 deletions
diff --git a/ttcp/ChangeLog b/ttcp/ChangeLog index 671d197..9ee3a40 100644 --- a/ttcp/ChangeLog +++ b/ttcp/ChangeLog @@ -1,3 +1,9 @@ +2007-08-16 Joel Sherrill <joel.sherrill@oarcorp.com> + + * init.c: Change clock tick to 1 millisecond. + * rtems_ttcp.c: Add CPU usage reporting. + * ttcp_orig/ttcp.c: Add -m option for delaying between writes. + 2007-06-21 Joel Sherrill <joel.sherrill@OARcorp.com> * init.c: More warnings removed. diff --git a/ttcp/init.c b/ttcp/init.c index a7a520f..8ca036d 100644 --- a/ttcp/init.c +++ b/ttcp/init.c @@ -27,7 +27,7 @@ #define CONFIGURE_MAXIMUM_SEMAPHORES 20 #define CONFIGURE_MAXIMUM_TASKS 20 -#define CONFIGURE_MICROSECONDS_PER_TICK 10000 +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 #define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) #define CONFIGURE_INIT_TASK_PRIORITY 100 diff --git a/ttcp/rtems_ttcp.c b/ttcp/rtems_ttcp.c index 0a4d81b..a828c66 100644 --- a/ttcp/rtems_ttcp.c +++ b/ttcp/rtems_ttcp.c @@ -85,6 +85,7 @@ getrusage(int ignored, struct rusage *ru) static void rtems_ttcp_exit (int code) { + rtems_cpu_usage_report(); rtems_task_wake_after( RTEMS_MILLISECONDS_TO_TICKS(1000) ); rtems_bsdnet_show_mbuf_stats (); rtems_bsdnet_show_if_stats (); @@ -160,6 +161,7 @@ ttcpTask (rtems_task_argument arg) printf ("or\n"); printf (" -t destination.internet.address\n"); } + rtems_cpu_usage_reset(); code = rtems_ttcp_main (argc, argv); rtems_ttcp_exit (code); } diff --git a/ttcp/ttcp_orig/ttcp.c b/ttcp/ttcp_orig/ttcp.c index aa0f7cc..a5a4ecb 100644 --- a/ttcp/ttcp_orig/ttcp.c +++ b/ttcp/ttcp_orig/ttcp.c @@ -47,6 +47,8 @@ /* #define BSD41a */ /* #define SYSV */ /* required on SGI IRIX releases before 3.3 */ +#define ENABLE_NANOSLEEP_DELAY + #include <stdio.h> #include <signal.h> #include <ctype.h> @@ -57,8 +59,12 @@ #include <netinet/tcp.h> #include <arpa/inet.h> #include <netdb.h> +#include <string.h> #include <sys/time.h> /* struct timeval */ +#include <unistd.h> +#include <stdlib.h> + #if defined(SYSV) #include <sys/times.h> #include <sys/param.h> @@ -106,6 +112,7 @@ char fmt = 'K'; /* output format: k = kilobits, K = kilobytes, * m = megabits, M = megabytes, * g = gigabits, G = gigabytes */ int touchdata = 0; /* access data after reading */ +long milliseconds = 0; /* delay in milliseconds */ struct hostent *addr; extern int errno; @@ -133,6 +140,7 @@ Options specific to -t:\n\ Options specific to -r:\n\ -B for -s, only output full blocks as specified by -l (for TAR)\n\ -T \"touch\": access each byte as it's read\n\ + -m ## delay for specified milliseconds between each write\n\ "; char stats[128]; @@ -156,6 +164,17 @@ sigpipe() { } +void millisleep(long msec) +{ +#if defined(ENABLE_NANOSLEEP_DELAY) + struct timespec req; + + req.tv_sec = msec / 1000; + req.tv_nsec = (msec % 1000) * 1000000; + + nanosleep( &req, NULL ); +#endif +} int main(argc,argv) int argc; char **argv; @@ -165,7 +184,7 @@ char **argv; if (argc < 2) goto usage; - while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:")) != -1) { + while ((c = getopt(argc, argv, "drstuvBDTb:f:l:m:n:p:A:O:")) != -1) { switch (c) { case 'B': @@ -188,6 +207,12 @@ char **argv; "ttcp: -D option ignored: TCP_NODELAY socket option not supported\n"); #endif break; + case 'm': + milliseconds = atoi(optarg); + #if !defined(ENABLE_NANOSLEEP_DELAY) + fprintf(stderr, "millisecond delay disabled\n"); + #endif + break; case 'n': nbuf = atoi(optarg); break; @@ -379,8 +404,10 @@ char **argv; if (trans) { pattern( buf, buflen ); if(udp) (void)Nwrite( fd, buf, 4 ); /* rcvr start */ - while (nbuf-- && Nwrite(fd,buf,buflen) == buflen) + while (nbuf-- && Nwrite(fd,buf,buflen) == buflen) { nbytes += buflen; + millisleep( milliseconds ); + } if(udp) (void)Nwrite( fd, buf, 4 ); /* rcvr end */ } else { if (udp) { |