Re: libpq and multi-threading - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: libpq and multi-threading
Date
Msg-id 20230503155450.zojytzy5ob5qo5tl@hjp.at
Whole thread Raw
In response to Re: libpq and multi-threading  (Michael Loftis <mloftis@wgops.com>)
List pgsql-general
On 2023-05-03 06:35:26 -0600, Michael Loftis wrote:
> That is not a thread. Linux man clone right at the start …
>
> “clone, __clone2, clone3 - create a child process”
>
> What you want is pthread_create (or similar)

clone is the system call which is used to create both processes and
threads (in the early days of Linux that generalization was thought to
be beneficial, but POSIX has all kinds of special rules for processes
and threads so it may actually have made stuff more complicated.)

I do agree that pthread_create (or the C11 thrd_create) is the way to
go. It will just call clone behind the scenes, but it will do so with
the right flags and possibly set up some other stuff expected by the
rest of the C library, too.

There may be good reasons to use the low level function in some cases.
But I'd say that in that case you should better know what that means
exactly.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment

pgsql-general by date:

Previous
From: "Michael J. Baars"
Date:
Subject: Re: libpq and multi-threading
Next
From: Geoff Winkless
Date:
Subject: Re: libpq and multi-threading