pipe latency

Lei Sun lei_sun at comcast.net
Mon Jan 30 18:35:38 UTC 2006


Hi: 
   This question may have nothing to do with uClibc, but again, i couldn't post on uClinux list. Appreciate if anyone could past this into that list.
   I wrote the following small program , just to test the pipe latency in uClinux and standard linux on my xscale based platform. Since someone mentioned bugs on MIPS platform, i wonder if anyone observed this.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
struct timeval tv_start, tv_stop;
int main(void)
{
    int fd[2];
    int msg = 0;
    if (pipe(fd) < 0 ) {
        fprintf(stderr, "pipe creationg failed\n");
        _exit(-1);
    }
    gettimeofday(&tv_start, 0);
    if(write(fd[1], &msg, sizeof(msg)) != sizeof(msg)) {
        fprintf(stderr, "write failed\n");
    }
    if(read(fd[0], &msg , sizeof(msg)) != sizeof(msg)) {
        fprintf(stderr, "read failed\n");
    }
    gettimeofday(&tv_stop, 0);

    fprintf(stderr, "start.tv_sec=%u start.tv_usec=%u, stop.tv_sec=%u stop.tv_usec=%u\n",
        tv_start.tv_sec, tv_start.tv_usec, tv_stop.tv_sec, tv_stop.tv_usec);

    fprintf(stderr, "msg=%d\n", msg);
    _exit(0);
}

Test result showed that on the average, it takes 20 us finishing read/write cycle on standard linux , while it takes 50 us in uClinux. I was expecting it getting faster on uClinux instead of the opposite. Could anyone explain this? or do a similar test with it?

Thank you!
lei 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/uclibc/attachments/20060130/ae068d95/attachment.htm 


More information about the uClibc mailing list