Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Oct 1998 09:44:27 -0400 (EDT)
From:      Daniel Eischen <eischen@vigrid.com>
To:        freebsd-current@FreeBSD.ORG, rrs@LMI.Net
Subject:   Re: pthread behavior
Message-ID:  <199810021344.JAA11670@pcnet1.pcnet.com>

next in thread | raw e-mail | index | archive | help
Robert Schulhof <rrs@LMI.Net> wrote:
>   I am not sure if this is the expected behavior according to the current
> IEEE standard, but sleep calls in any thread seem to suspend a process.
>  Also when a thread waits on a semop it seems to put the whole
> process to sleep.  Are semaphores thread safe?  I've tried compiling
> with cc and with egcs 1.1.  The weird part is that the program will
> occasionally work correctly  ( The semop calls, that is.  sleep doesn't
> work).  This program behaves as I expect Solaris 2.5.1.  Under FreeBSD
> 2.2.7-Stable it freezes my terminal :-)  Might be pilot error.

semop isn't currently wrapped by the threads library.  You
should submit a PR so it doesn't get lost.  

sleep shouldn't put the process to sleep - other threads 
should continue to run.  My tests with sleep don't exhibit
this behaviour.

> ACE wrappers, which worked before the recent changes to libc_r, now
> produces the following in the Semaphore/Threads test:
> 
> Fatal error 'Dead thread has resumed' at line ? in file /usr/src/src/lib/libc_r/
> uthread/uthread_exit.c (errno = ?)
> 
> I get this error about 30% of the time.  I'm just learning how to use
> ACE wrappers so I shouldn't attempt to figure that one out. This was after 
> cvsup around 9:30 PM PDT 30 Sep.  

Is this stable or current (you mention stable above)?

> Thanks! I know you're busy so ignore unless this helps with the 3.0 Beta
> shakeout.  I include the test below. define TEST_SLEEP to test sleep 
> in a thread.

semop isn't threaded, so you can't test sleep because your test
program is going to hang the process waiting for a semaphore 
to be released.

Are you sure you need semaphores?  Unless you're communicating with
another process, you can use mutexes and condition variables to
synchronize threads.

Dan Eischen
eischen@vigrid.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810021344.JAA11670>