* POSIX threads and Tru64 5.1a woes
@ 2002-04-21 18:50 Steve Young
2002-04-23 12:29 ` David Butenhof
0 siblings, 1 reply; 6+ messages in thread
From: Steve Young @ 2002-04-21 18:50 UTC (permalink / raw)
I have been working on a simple little gnutella client over the past couple
of months, mostly to learn a little about network programming. It works fine
under Linux,(free|open|net)BSD and Solaris.
However, on Tru64 5.1a it chokes pretty bad.
After running for a minute or so with a live network connection, the process
goes into uninterruptible sleep.
Using ladebug and reverting to a previous version of the program that used
the usual fork rather than POSIX threads I am 99% sure that the problem is
related to how I am using the POSIX threads library. The program is based on
the example of a pre-threaded server in UNIX Network Programming 2nd ed. on
pages 758-759. The threads seem to just all get stuck sleeping in the call
to pthread_cond_wait() and they just don't catch the pthread_cond_signal().
Of course, the obvious point of failure is myself; a simple CS student (for
three more weeks... joy!)
However, it DOES work (tested for days and days) on Linux and Solaris
whereas I am lucky if it runs more than one minute on Tru64.
Has anyone ever experienced similar problems w/ POSIX threads and Tru64?
- Steve Young
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: POSIX threads and Tru64 5.1a woes
2002-04-21 18:50 POSIX threads and Tru64 5.1a woes Steve Young
@ 2002-04-23 12:29 ` David Butenhof
2002-04-23 18:18 ` Thomas Losness
0 siblings, 1 reply; 6+ messages in thread
From: David Butenhof @ 2002-04-23 12:29 UTC (permalink / raw)
Steve Young wrote:
> I have been working on a simple little gnutella client over the past
> couple of months, mostly to learn a little about network programming. It
> works fine under Linux,(free|open|net)BSD and Solaris.
> However, on Tru64 5.1a it chokes pretty bad.
>
> After running for a minute or so with a live network connection, the
> process goes into uninterruptible sleep.
>
> Using ladebug and reverting to a previous version of the program that used
> the usual fork rather than POSIX threads I am 99% sure that the problem is
> related to how I am using the POSIX threads library. The program is based
> on the example of a pre-threaded server in UNIX Network Programming 2nd
> ed. on pages 758-759. The threads seem to just all get stuck sleeping in
> the call to pthread_cond_wait() and they just don't catch the
> pthread_cond_signal(). Of course, the obvious point of failure is myself;
> a simple CS student (for three more weeks... joy!)
> However, it DOES work (tested for days and days) on Linux and Solaris
> whereas I am lucky if it runs more than one minute on Tru64.
>
> Has anyone ever experienced similar problems w/ POSIX threads and Tru64?
While bugs certainly are uncovered in the thread library, such a fundamental
bug as you imply is quite unlikely. If there IS a problem in the library,
it's specific to a situation substantially more complicated than can be
plausibly inferred from your terse description.
First, what do you mean by "uninterruptible sleep"? Are you saying that the
state of the kernel thread involved is "U" as shown by "ps m"? (Nevermind
for the moment that it's impossible to reliably associate a kernel thread
with an application thread from a ps display.) Otherwise, it's not
"uninterruptible", so you might simply mean that your application has
failed to normally terminate the wait condition. Though in life (and
especially in programming) there are few guarantees, this is likely to be
an application problem.
You should consider using Visual Threads to analyze how your application
uses thread functions. It'll diagnose obvious problems, and many unobvious
problems. If your system doesn't already have Visual Threads, check out
http://www.compaq.com/products/software/visualthreads/download-tru64.html
/------------------[ David.Butenhof@compaq.com ]------------------\
| Compaq Computer Corporation POSIX Thread Architect |
| My book: http://www.awl.com/cseng/titles/0-201-63392-2/ |
\-----[ http://home.earthlink.net/~anneart/family/dave.html ]-----/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: POSIX threads and Tru64 5.1a woes
2002-04-23 12:29 ` David Butenhof
@ 2002-04-23 18:18 ` Thomas Losness
2002-04-24 13:00 ` David Butenhof
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Losness @ 2002-04-23 18:18 UTC (permalink / raw)
At the risk of sounding like I'm flaming David and Compaq, I don't agree
that
fundamental problems such as the one Steve describes are as rare as we'd all
like.
There is a bug in Tru64 5.1A having to do with POSIX shared memory and
the changes made to the Universal Cache Buffer. I have a small test program
that demonstrates a realtime application using POSIX threads, shared memory,
and semaphores. This program runs at 50Hz and does some nonsense "work"
during each of the intervals. The set of work takes about 6 milliseconds
for each
interval on a DS20E with two CPUS and 2GB of memory.
The bug shows up when the 'update' program is run by the OS to sync the
disks.
At that point, my realtime program running at high priority and with FIFO
scheduling
will take anywhere from 12-50 milliseconds to do the same work it was doing
in 6 milliseconds. In the case of a realtime application running at 50Hz,
as soon
as the work interval takes more than 20 milliseconds, we've just busted a
frame.
This same source compiled on a Tru64 4.0G machine works just fine. Now,
a realtime application is certainly not the norm for most Compaq customers,
but I
would think those 50 millisecond hits would be awfully painful to customers
running
webservers or database servers on Tru64 5.x. If you're using POSIX shared
memory
and Tru64 5.1A UNIX, you should be aware that this problem may hit you
pretty hard.
If anyone is interested in obtaining my test program to see for themselves,
please
email me using tlosness as the portion in front of the at symbol and
aerosysengr
for the company name with com at the end (I do hate SPAM, so I won't post
me email address in an obvious manner).
Please note that the current workaround is to replace POSIX shared memory
with SYSV shared memory. The test source I have also incorporates this and
can be compiled in that manner by setting an #define.
Tom Losness
Aero Systems Engineering
"David Butenhof" <David.Butenhof@compaq.com> wrote in message
news:atcx8.15$0P4.247957@cacnews.cac.cpqcorp.net...
> Steve Young wrote:
>
> > I have been working on a simple little gnutella client over the past
> > couple of months, mostly to learn a little about network programming. It
> > works fine under Linux,(free|open|net)BSD and Solaris.
> > However, on Tru64 5.1a it chokes pretty bad.
> >
> > After running for a minute or so with a live network connection, the
> > process goes into uninterruptible sleep.
> >
> > Using ladebug and reverting to a previous version of the program that
used
> > the usual fork rather than POSIX threads I am 99% sure that the problem
is
> > related to how I am using the POSIX threads library. The program is
based
> > on the example of a pre-threaded server in UNIX Network Programming 2nd
> > ed. on pages 758-759. The threads seem to just all get stuck sleeping in
> > the call to pthread_cond_wait() and they just don't catch the
> > pthread_cond_signal(). Of course, the obvious point of failure is
myself;
> > a simple CS student (for three more weeks... joy!)
> > However, it DOES work (tested for days and days) on Linux and Solaris
> > whereas I am lucky if it runs more than one minute on Tru64.
> >
> > Has anyone ever experienced similar problems w/ POSIX threads and Tru64?
>
> While bugs certainly are uncovered in the thread library, such a
fundamental
> bug as you imply is quite unlikely. If there IS a problem in the library,
> it's specific to a situation substantially more complicated than can be
> plausibly inferred from your terse description.
>
> First, what do you mean by "uninterruptible sleep"? Are you saying that
the
> state of the kernel thread involved is "U" as shown by "ps m"? (Nevermind
> for the moment that it's impossible to reliably associate a kernel thread
> with an application thread from a ps display.) Otherwise, it's not
> "uninterruptible", so you might simply mean that your application has
> failed to normally terminate the wait condition. Though in life (and
> especially in programming) there are few guarantees, this is likely to be
> an application problem.
>
> You should consider using Visual Threads to analyze how your application
> uses thread functions. It'll diagnose obvious problems, and many unobvious
> problems. If your system doesn't already have Visual Threads, check out
> http://www.compaq.com/products/software/visualthreads/download-tru64.html
>
> /------------------[ David.Butenhof@compaq.com ]------------------\
> | Compaq Computer Corporation POSIX Thread Architect |
> | My book: http://www.awl.com/cseng/titles/0-201-63392-2/ |
> \-----[ http://home.earthlink.net/~anneart/family/dave.html ]-----/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: POSIX threads and Tru64 5.1a woes
2002-04-23 18:18 ` Thomas Losness
@ 2002-04-24 13:00 ` David Butenhof
2002-04-24 15:13 ` Thomas Losness
0 siblings, 1 reply; 6+ messages in thread
From: David Butenhof @ 2002-04-24 13:00 UTC (permalink / raw)
Thomas Losness wrote:
> At the risk of sounding like I'm flaming David and Compaq, I don't agree
> that
> fundamental problems such as the one Steve describes are as rare as we'd
> all like.
>
> There is a bug in Tru64 5.1A having to do with POSIX shared memory and
> the changes made to the Universal Cache Buffer. I have a small test
> program that demonstrates a realtime application using POSIX threads,
> shared memory,
> and semaphores. This program runs at 50Hz and does some nonsense "work"
> during each of the intervals. The set of work takes about 6 milliseconds
> for each
> interval on a DS20E with two CPUS and 2GB of memory.
While I can understand how someone completely dependent on realtime shared
memory synchronization might consider this problem "fundamental", and
certainly that you might be upset, it's hardly on the same level of
"fundamental" as a condition variable wait failing to wake up. You started
out, to begin with, by listing a whole set of specific conditions; the
original poster has not. As I said, I can only presume there are a lot of
specialized conditions that aren't explained and cannot be inferred from
the description.
By the way -- if you're writing a realtime thread program that's dependent
on realtime synchronization with external state (such as hardware, or
threads in other processes), I hope you're using SCS (system contention
scope) threads? While the default PCS threads are more system-friendly and
lighter-weight for most applications, they're NOT appropriate for such
realtime operations because the scheduling state of a PCS thread contends
only against other threads within the process. The kernel threads (or
"virtual processors") on which PCS threads are scheduled have the kernel
policy and priority of the process, which is generally lower than the
visible thread state (e.g., the default timeshare priority 19).
> The bug shows up when the 'update' program is run by the OS to sync the
> disks.
> At that point, my realtime program running at high priority and with FIFO
> scheduling
> will take anywhere from 12-50 milliseconds to do the same work it was
> doing
> in 6 milliseconds. In the case of a realtime application running at 50Hz,
> as soon
> as the work interval takes more than 20 milliseconds, we've just busted a
> frame.
>
> This same source compiled on a Tru64 4.0G machine works just fine. Now,
> a realtime application is certainly not the norm for most Compaq
> customers, but I
> would think those 50 millisecond hits would be awfully painful to
> customers running
> webservers or database servers on Tru64 5.x. If you're using POSIX shared
> memory
> and Tru64 5.1A UNIX, you should be aware that this problem may hit you
> pretty hard.
>
> If anyone is interested in obtaining my test program to see for
> themselves, please
> email me using tlosness as the portion in front of the at symbol and
> aerosysengr
> for the company name with com at the end (I do hate SPAM, so I won't post
> me email address in an obvious manner).
>
> Please note that the current workaround is to replace POSIX shared memory
> with SYSV shared memory. The test source I have also incorporates this
> and can be compiled in that manner by setting an #define.
That's unfortunate, and I'm sure the VM people would love to hear about
this. Have you done anything to inform them? Like entering a formal problem
report that can be tracked and prioritized? If you have, then presumably
you attached your sample code and they already have it.
/------------------[ David.Butenhof@compaq.com ]------------------\
| Compaq Computer Corporation POSIX Thread Architect |
| My book: http://www.awl.com/cseng/titles/0-201-63392-2/ |
\-----[ http://home.earthlink.net/~anneart/family/dave.html ]-----/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: POSIX threads and Tru64 5.1a woes
2002-04-24 13:00 ` David Butenhof
@ 2002-04-24 15:13 ` Thomas Losness
2002-04-25 12:05 ` David Butenhof
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Losness @ 2002-04-24 15:13 UTC (permalink / raw)
David,
Thank you for your reply. I realize that it might have been inappropriate
to
jump off of Steve's post with my own, but I still believe my original point
is valid. Bugs of the level Steve and I describe can certainly be part of
the Operating System and it may be a while before they are noticed and
fixed.
On the helpful questions you had: Yes, I am using SCS and yes I have
submitted this bug to Compaq along with my example source. They
acknowledge that it is a problem. Unfortunately, they will not be fixing
it any time soon. I realize that my application may be narrow in the
larger scheme of things, but I still believe that serious problems can and
do occur.
Thanks for your suggestions,
Tom Losness
"David Butenhof" <David.Butenhof@compaq.com> wrote in message
news:r%xx8.9$Qr5.351281@cacnews.cac.cpqcorp.net...
> Thomas Losness wrote:
>
> > At the risk of sounding like I'm flaming David and Compaq, I don't agree
> > that
> > fundamental problems such as the one Steve describes are as rare as we'd
> > all like.
> >
> > There is a bug in Tru64 5.1A having to do with POSIX shared memory and
> > the changes made to the Universal Cache Buffer. I have a small test
> > program that demonstrates a realtime application using POSIX threads,
> > shared memory,
> > and semaphores. This program runs at 50Hz and does some nonsense "work"
> > during each of the intervals. The set of work takes about 6
milliseconds
> > for each
> > interval on a DS20E with two CPUS and 2GB of memory.
>
> While I can understand how someone completely dependent on realtime shared
> memory synchronization might consider this problem "fundamental", and
> certainly that you might be upset, it's hardly on the same level of
> "fundamental" as a condition variable wait failing to wake up. You started
> out, to begin with, by listing a whole set of specific conditions; the
> original poster has not. As I said, I can only presume there are a lot of
> specialized conditions that aren't explained and cannot be inferred from
> the description.
>
> By the way -- if you're writing a realtime thread program that's dependent
> on realtime synchronization with external state (such as hardware, or
> threads in other processes), I hope you're using SCS (system contention
> scope) threads? While the default PCS threads are more system-friendly and
> lighter-weight for most applications, they're NOT appropriate for such
> realtime operations because the scheduling state of a PCS thread contends
> only against other threads within the process. The kernel threads (or
> "virtual processors") on which PCS threads are scheduled have the kernel
> policy and priority of the process, which is generally lower than the
> visible thread state (e.g., the default timeshare priority 19).
>
> > The bug shows up when the 'update' program is run by the OS to sync the
> > disks.
> > At that point, my realtime program running at high priority and with
FIFO
> > scheduling
> > will take anywhere from 12-50 milliseconds to do the same work it was
> > doing
> > in 6 milliseconds. In the case of a realtime application running at
50Hz,
> > as soon
> > as the work interval takes more than 20 milliseconds, we've just busted
a
> > frame.
> >
> > This same source compiled on a Tru64 4.0G machine works just fine. Now,
> > a realtime application is certainly not the norm for most Compaq
> > customers, but I
> > would think those 50 millisecond hits would be awfully painful to
> > customers running
> > webservers or database servers on Tru64 5.x. If you're using POSIX
shared
> > memory
> > and Tru64 5.1A UNIX, you should be aware that this problem may hit you
> > pretty hard.
> >
> > If anyone is interested in obtaining my test program to see for
> > themselves, please
> > email me using tlosness as the portion in front of the at symbol and
> > aerosysengr
> > for the company name with com at the end (I do hate SPAM, so I won't
post
> > me email address in an obvious manner).
> >
> > Please note that the current workaround is to replace POSIX shared
memory
> > with SYSV shared memory. The test source I have also incorporates this
> > and can be compiled in that manner by setting an #define.
>
> That's unfortunate, and I'm sure the VM people would love to hear about
> this. Have you done anything to inform them? Like entering a formal
problem
> report that can be tracked and prioritized? If you have, then presumably
> you attached your sample code and they already have it.
>
> /------------------[ David.Butenhof@compaq.com ]------------------\
> | Compaq Computer Corporation POSIX Thread Architect |
> | My book: http://www.awl.com/cseng/titles/0-201-63392-2/ |
> \-----[ http://home.earthlink.net/~anneart/family/dave.html ]-----/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: POSIX threads and Tru64 5.1a woes
2002-04-24 15:13 ` Thomas Losness
@ 2002-04-25 12:05 ` David Butenhof
0 siblings, 0 replies; 6+ messages in thread
From: David Butenhof @ 2002-04-25 12:05 UTC (permalink / raw)
Thomas Losness wrote:
> Thank you for your reply. I realize that it might have been inappropriate
> to
> jump off of Steve's post with my own, but I still believe my original
> point
> is valid. Bugs of the level Steve and I describe can certainly be part of
> the Operating System and it may be a while before they are noticed and
> fixed.
But that "bugs of the level" phrase is exactly my point. Your bug and
Steve's may NOT be "of the same level". You, for exmaple, provided a much
more detailed description, making it possible to make some straightforward
judgement of the nature and scope; a performance degradation when flushing
POSIX shared memory buffers to disk. Important, certainly; but fairly
subtle.
No such judgement is possible with Steve's description, which basically
comes down to "condition variables don't work". Well, condition variables
DO work. Just as shared memory does work, and even synchronizing them with
the disk does work. So how are we to judge the scope and nature of Steve's
problem? It's clearly NOT what the simplistic statement implies, and
there's no additional information. This would be like if you had made the
claim that "shared memory doesn't work".
My response was simply that there's too much unknown to do any more than
rebut the generalization that "condition variables don't work", and to ask
for more information.
> On the helpful questions you had: Yes, I am using SCS and yes I have
> submitted this bug to Compaq along with my example source. They
> acknowledge that it is a problem. Unfortunately, they will not be fixing
> it any time soon. I realize that my application may be narrow in the
> larger scheme of things, but I still believe that serious problems can and
> do occur.
Of course they can, but I was talking about the nature, not the severity.
You've got a performance degradation when POSIX shared memory backed by
disk collides with realtime scheduling. While it's too bad that the
substantial pre-release testing didn't catch that, it's easy to imagine how
that could happen. I'm not trying to make excuses for anyone, but nobody
can afford to test everything and every possible interaction; some things
are inevitably going to be missed. But hypothesizing that a condition wait
wouldn't wake up under normal and correct usage? That's a very different
matter. It'd have to go out with NO testing to miss that. Again, what I
SAID was simply that, if there IS a bug, the circumstances are vastly more
complicated and subtle than suggested by what Steve wrote. We have a large
test suite, in addition to the Java, Ada, and UNIX98 test suites; we also
test with major applications that have been known to be "stressful". Even
so, we can't test every possible interaction into which threads may be
forced... there are too many possibilities. But "a condition variable wait
doesn't wake up"? C'mon now: give us some credit, please. ;-)
And, finally, I was trying to do this without being offensive to Steve, who
I'm sure didn't deliberately set out to omit all useful information from
his post. I'm afraid this response is treading a bit closer to the line
than I'd really like, but I really don't want to ignore this digression,
and I also don't want to take the time that might be required to phrase
everything as carefully as I'd really like. So, if I've stepped on toes,
please forgive me.
/------------------[ David.Butenhof@compaq.com ]------------------\
| Compaq Computer Corporation POSIX Thread Architect |
| My book: http://www.awl.com/cseng/titles/0-201-63392-2/ |
\-----[ http://home.earthlink.net/~anneart/family/dave.html ]-----/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-04-25 12:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-21 18:50 POSIX threads and Tru64 5.1a woes Steve Young
2002-04-23 12:29 ` David Butenhof
2002-04-23 18:18 ` Thomas Losness
2002-04-24 13:00 ` David Butenhof
2002-04-24 15:13 ` Thomas Losness
2002-04-25 12:05 ` David Butenhof
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox