Copy-on-write fork

Chris January chris@atomice.net
Fri Apr 19 19:18:00 GMT 2002


This is mainly a question aimed at Christopher Faylor, but maybe someone
else knows the answer.
My question is, with regard to Chris's post "Re: copy-on-write (oh well)"
[http://www.cygwin.com/ml/cygwin-developers/2000-07/msg00026.html], does
anyone know why a copy-on-write implementation of fork takes longer than the
current Cygwin version??
BTW, I've not had any problems forking beyond the first level using the
example code from 'Window NT/2000 Native API reference'. What problems did
you encounter Chris? My test case is probably not rigorous enough.

A test program and statistics are shown below which clearly show Cygwin's
fork implementation in the lead.

#include <unistd.h>
#include <stdio.h>
#include <windows.h>

int main(void) {
    int pid, i;
    DWORD dwStartTicks, dwEndTicks;
    dwStartTicks = GetTickCount();
    for (i=0;i<100;i++) {
        pid = fork();
        if (!pid)
            exit(0);
    }
    dwEndTicks = GetTickCount();
    printf("average fork time = %g ms\n", (dwEndTicks -
dwStartTicks)/1000.0);
}

test uses the copy-on-write implementation
test2 uses Cygwin's implementation

$ time ./test
average fork time = 3.345 ms

real    0m3.391s
user    0m0.020s
sys     0m0.030s

$ time ./test2
average fork time = 1.972 ms

real    0m2.043s
user    0m0.060s
sys     0m0.220s

Regards
Chris



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list