On Wed, Aug 02, 2000, Soonmyung Hong wrote: > I found same program based on pth provide different operation between > different platforms. > > I think I can avoid this problem by explicit pth_yield or condition > variables, but I want to know what makes this difference. > > Result on FreeBSD Result on Linux > 3.5R + pth-1.3.6 kernel 2.2.14 + pth-1.3.6 > 4.1R + pth-1.3.7 kernel 2.2.15 + pth-1.3.5 > > all spawned all spawned > child 0 spawned child 0 spawned > child 1 spawned child 0 done > child 2 spawned child 1 spawned > child 3 spawned child 1 done > child 4 spawned child 2 spawned > child 5 spawned child 2 done > child 6 spawned child 3 spawned > child 7 spawned child 3 done > child 8 spawned child 4 spawned > child 9 spawned child 4 done > child 0 done child 5 spawned > child 1 done child 5 done > child 2 done child 6 spawned > child 3 done child 6 done > child 4 done child 7 spawned > child 5 done child 7 done > child 6 done child 8 spawned > child 7 done child 8 done > child 8 done child 9 spawned > child 9 done child 9 done > > below is my test program > > [...] > static void > child(void *_arg) > [...] > > int > main(int argc, char *argv[]) > { > [...] > printf("all spawned\n"); > sleep(10); > pth_mutex_release(&lock); > [...] A few points: 1. Your child() function has to use a return type of "void *" and it has to return at least a value (usually NULL). Check the pth manual page. 2. The difference is caused by your sleep(3) call. Keep in mind that sleep(3) is libc's sleep(3) and this doesn't use the user-space scheduler of Pth. So you have to use pth_sleep() instead. But now why the difference because of sleep(3). I'm sure under FreeBSD you had used --enable-syscall-soft (check your installed pth.h for the define of PTH_SYSCALL_SOFT) and under Linux you have not used this. Then the behaviour is the expected one, because with PTH_SYSCALL_SOFT, your sleep() call translates to pth_sleep() and this way the threads startup "in parallel" while the parent sleeps. You should recognize that the "child 0 spawned" comes immediately under FreeBSD and the sleep happens after "child 9 spawned" while on Linux the sleep happens already before the "child 0 spawned". Ralf S. Engelschall [EMAIL PROTECTED] www.engelschall.com ______________________________________________________________________ GNU Portable Threads (Pth) http://www.gnu.org/software/pth/ User Support Mailing List [EMAIL PROTECTED] Automated List Manager (Majordomo) [EMAIL PROTECTED]