Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #90793

Re: [C/POSIX] pthread_exit()

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: [C/POSIX] pthread_exit()
Date 2016-07-22 13:26 -0400
Organization A noiseless patient Spider
Message-ID <nmtkvq$5nd$1@dont-email.me> (permalink)
References <slrnnovao6.boo.jkb@rayleigh.systella.fr> <16443da7-cef3-04d5-ced6-1fb40fd05b64@verizon.net> <nmt60a$246$1@gioia.aioe.org>

Show all headers | View raw


On 07/22/2016 09:10 AM, Randy Howard wrote:
> On 7/20/16 12:42 PM, James R. Kuyper wrote:
>> On 07/20/2016 12:47 PM, JKB wrote:
>>>     Hello,
>>>
>>>     I'm debugging a huge program that can enter in deadlock on a
>>>     pthread_exit() syscall. I use gcc compiler on Linux or NetBSD.
> 
> clang has some pretty get sanitizers now (even if you prefer gcc most
> of the time for some bizarre reason, it's worth using the sanitizers,
> especially the threading one if your platform supports them. I'm
> pretty sure BSD does if not Linux.
> 
>>
>> As you yourself noted in your subject line, this is a POSIX-specific
>> question. As such, you're more likely to find people who can help you if
>> you post in a POSIX-specific forum, such as comp.unix.programmer.
> 
> Most of the formerly useful Usenet groups have become practically
> worthless, including the threads specific one which used to be quite
> active with real discussions about threading.

If the best available forum (note: usenet is not the entire world -
there's many other types of forums) for discussing POSIX programs has
nobody helpful that you can talk to, then POSIX must be dead. I doubt
that it's dead - most of the computers I've ever used in the past 40
years have been compatible with POSIX, and all of the computers I've
programmed for in the past 30 years have been POSIX compatible. I just
think you haven't found the right forum.
It certainly isn't this forum - otherwise the original question would
have produced a much larger number of more helpful responses.

>> C2011 added the new <threads.h> header, and a lot of features to support
>> multi-thread programs. If you were to re-writr this program to make use
>> of <threads.h> rather than <pthread.h>, then the corresponding question
>> about thrd_exit() could be asked here, in a reasonable expectation that
>> someone here might be able to answer it.
> 
> I can't think of a single reason why anyone would prefer to use that
> ridiculous stuff in C11 for threading. ... 

I was merely explaining what would have to be different to justify
posting a question like his in this forum. I was not endorsing or
recommending the use of <threads.h> - I don't have enough experience
with multi-threaded code to justify endorsing any particular way of
doing it.

> ... pthreads is already there and
> well vetted.

Well, that comment implicitly points out the most likely reason for
using C11 threads: when "pthreads is" NOT "already there". I've had
people point out that the "P" in POSIX stands for "Portable", as if
putting that P there made it portable. It isn't. POSIX is widespread,
but C is even more widely spread - it can be and has been implemented on
many platforms which do not support POSIX, many of which support
multi-threaded code by means that are incompatible with POSIX - but
which may still allow <threads.h> to be implemented as a thin wrapper
over native threading functions.

Obviously, code targeted only at POSIX platforms can safely rely upon
<pthreads.h>, and code targeted only at a set of non-POSIX platforms
that supports a different threading library can rely on that library.
However, if for any reason if you want your code to be portable to
systems with two or more different incompatible threading libraries,
then <threads.h> becomes a viable alternative to writing two or more
entirely different versions of your program. Of course, that only works
if all of the systems you're targeting support <threads.h>, and only if
<threads.h> provides all of the features that you'll need.

That might be an uncommon need, but I don't understand why you're so
sure that it's a non-existent need. Perhaps you feel that all the world
faces exactly the same problems you do, so if you've never needed
something like this, nobody needs it?

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-20 16:47 +0000
  Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-20 13:42 -0400
    Re: [C/POSIX] pthread_exit() Keith Thompson <kst-u@mib.org> - 2016-07-20 11:33 -0700
    Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-21 10:10 +0000
    Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-22 08:10 -0500
      Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 13:42 +0000
        Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-22 09:44 -0500
          Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 14:48 +0000
      Re: [C/POSIX] pthread_exit() Richard Heathfield <rjh@cpax.org.uk> - 2016-07-22 14:52 +0100
      Re: [C/POSIX] pthread_exit() supercat@casperkitty.com - 2016-07-22 08:51 -0700
      Re: [C/POSIX] pthread_exit() James Kuyper <jameskuyper@verizon.net> - 2016-07-22 13:26 -0400
      Re: [C/POSIX] pthread_exit() Keith Thompson <kst-u@mib.org> - 2016-07-22 10:28 -0700
        Re: [C/POSIX] pthread_exit() Ian Collins <ian-news@hotmail.com> - 2016-07-23 16:12 +1200
        Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-23 16:43 -0500
          Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-23 18:17 -0400
            Re: [C/POSIX] pthread_exit() Keith Thompson <kst-u@mib.org> - 2016-07-23 20:45 -0700
            Re: [C/POSIX] pthread_exit() James Kuyper <jameskuyper@verizon.net> - 2016-07-24 07:27 -0400
              Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-25 15:22 -0500
                Re: [C/POSIX] pthread_exit() Ian Collins <ian-news@hotmail.com> - 2016-07-26 08:26 +1200
                Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-25 16:32 -0400
                Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-25 15:52 -0500
                Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-25 16:59 -0400
                Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-25 16:36 -0500
  Re: [C/POSIX] pthread_exit() Johann Klammer <klammerj@NOSPAM.a1.net> - 2016-07-21 11:54 +0200
    Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 08:17 +0000
      Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 08:47 +0000
  Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-23 00:52 +0200
    Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 11:43 +0000
      Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 13:47 +0200
        Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 11:58 +0000
          Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 14:00 +0200
            Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 12:18 +0000
              Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 14:20 +0200
                Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 12:26 +0000
                Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 14:28 +0200
                Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 12:35 +0000
                Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 13:44 +0000

csiph-web