Oops! Ok I understand why things aren't working as they should now. When I
build pth I specified the --enable-pthread option, which according to the
INSTALL file, this should force on --enable-soft-syscall, which it doesn't.

Someone may want to fix the following paragraph in the file INSTALL, if I am
interpreting it correctly. Following is the passage I refer to.

 --enable-pthread: build with pthread library (default=no)
      This enables the building and installation of the
      POSIX Threads ("pthread") emulation API for Pth.
      This per default forces --enable-syscall-soft.

Now compiling the "test_pthread" program behaves as i would expect it to,
when the sleep call is reached it now yeilds and the next thread runs.

Thanks for your help.

Sincerly
Stephen Alstrin

-----Original Message-----
From: Matthew Mondor [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 2:33 PM
To: [EMAIL PROTECTED]
Subject: Re: PTH is broke or I don't understand threads.


On Tue, Apr 01, 2003 at 12:15:44PM -0800, Steve Alstrin wrote:

> I compiled the test program, included with distro, and it appears that no
> thread will start until a join is done on it. When I compile the test
> program "test_pthread" with native threads the threads start after the
> pthread_create call, whereas when compiled with pth threads, each thread
> only starts when the join for that thread is done, and will not allow the
> other threads to run until the previous join has completed.
> 
> Is this a bug, or does all the other thread packages behave incorrectly?
> 
> Any help would be greatly appreciated, i.e. my job depends on it.

I am not 100% sure if I understand the question, but I have the impression
that your problem may be related to the non-preemptive nature of PTh...
Your applications should either call pth_yield() or pth_*() IO functions
(which can internally be called automatically by standard syscalls if
PTh was compiled with hard-syscall option) for it to delegate control back
to the CPU and therefore allow other threads to execute. (The same applies
calling pthread_*() functions rather than the Pth specific pth_*() ones)

Hmm also make sure that you are using pth(read)_join() according to
POSIX defined semantics (threads should only be joined when the current
thread wants to wait until thread termination, and that thread should not
have been started using the asynchroneous flag). Otherwise, if the threads
were started using the asynchroneous DETACH flag, they are expected to
free their resources and exit naturally themselves at pth(read)_exit(),
and should not be joined. This behavior is expected for all POSIX
pthread_*() functions, no matter the implementation.

Hope this helps,

Matt

______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
Development Site                      http://www.ossp.org/pkg/lib/pth/
Distribution Files                          ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots                 ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]
______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
Development Site                      http://www.ossp.org/pkg/lib/pth/
Distribution Files                          ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots                 ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to