• OT: Windows (Was: Re: Open Source does not mean easily re-compile-able)

    From Salvador Mirzo@21:1/5 to Muttley@dastardlyhq.com on Sat Jan 4 08:31:05 2025
    Muttley@dastardlyhq.com writes:

    On Fri, 03 Jan 2025 18:15:25 GMT
    scott@slp53.sl.home (Scott Lurndal) gabbled:
    Paul <nospam@needed.invalid> writes:
    On Thu, 1/2/2025 11:29 AM, Scott Lurndal wrote:

    Why would you expect the link step to require a lot of
    memory? The linker builds an elf executable from the contents
    of ELF object files, one ELF section at a time. It doesn't
    construct the entire ELF executable in memory before writing it out.


    It's based on experience, not imagination.

    I've built Thunderbird on both Windows and Linux.
    It was the Windows build that left a bad taste.
    Once you repeatedly have build failures during linking,
    you are always looking for it.


    Ah, well windows. You need not elaborate.

    I've been fortunate to have never built software in a
    microsoft environment (aside an optical jukebox driver
    for NT3.51 once on a contract job - even then I did
    all the editing on unix and just compiled and tested
    on the windows box).

    I did a Windows C++ job for a year. I still can't believe how complicated Visual Studio (2017 IIRC) made the most basic things such as setting library and include paths which were buried 2 or 3 levels down in some sub menu not to mention all the "project" BS which forced a certain structure on to your code filesystem layout which I didn't particularly want. Also the fact that console and GUI apps require a totally different project setup and boiler plate
    code from the start is just mind boggling.

    They always try to make things pretty and easy to use, but you end up
    with that. I think the only way to tolerate that is to be born and
    raised in such thing. Modularization is likely the most important thing
    in programming and it's hard to minimally praise Microsoft on
    modularization. For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Salvador Mirzo@21:1/5 to Lawrence D'Oliveiro on Sat Jan 4 19:17:15 2025
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation
    on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of
    a bunch of them at DEC. They would instinctively turn away from Unix ways
    of doing things, like forking multiple processes. So the systems they
    created did not encourage such techniques.

    Is that Dave with a YouTube channel?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Salvador Mirzo on Sun Jan 5 00:47:19 2025
    On Sat, 04 Jan 2025 19:17:15 -0300, Salvador Mirzo wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Windows NT was masterminded by Dave Cutler ...

    Is that Dave with a YouTube channel?

    No, that’s a different former Microsoftie, but he has had Cutler on his channel for an extended interview.

    I found it ironic that there was a PiDP-11, I think it was, placed within arm’s reach behind the guy during the entire interview. You know, the
    PDP-11 emulator that runs on a Linux-based Raspberry Pi. I wonder if the Unix-hater ever noticed that ...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to All on Sun Jan 5 16:40:33 2025
    On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation
    on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible >for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of
    a bunch of them at DEC. They would instinctively turn away from Unix ways
    of doing things, like forking multiple processes. So the systems they
    created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a process expected to everything itself sequentially?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@dastardlyhq.com on Sun Jan 5 17:14:14 2025
    Muttley@dastardlyhq.com writes:
    On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation
    on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible >>for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of >>a bunch of them at DEC. They would instinctively turn away from Unix ways >>of doing things, like forking multiple processes. So the systems they >>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >process expected to everything itself sequentially?

    The first shared memory multiprocessor VAX was the 11/782. It was
    not considered SMP. I worked with four 11/780's sharing a 4MB MA-780
    for three years in the early 80s - the shared memory could be used
    primarily for inter-process communications (e.g. mailboxes) or one
    could install commonly used program read-only 'text' regions in the shared memory to reduce the memory presure on each of the 780s. I developed
    a DECnet ACP to support transport within the cluster via MA-780.

    VMS itself did not leverage threads in the modern sense at that point.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@dastardlyhq.com on Sun Jan 5 21:09:55 2025
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation
    on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible >>for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of >>a bunch of them at DEC. They would instinctively turn away from Unix ways >>of doing things, like forking multiple processes. So the systems they >>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system
    architecture provides a mechanisms to signal completion; ASTs,
    mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastardlyHQ.org@21:1/5 to All on Mon Jan 6 08:36:27 2025
    On Sun, 5 Jan 2025 21:09:55 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation >>>on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible >>>for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of >>>a bunch of them at DEC. They would instinctively turn away from Unix ways >>>of doing things, like forking multiple processes. So the systems they >>>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >>process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system
    architecture provides a mechanisms to signal completion; ASTs,
    mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    I imagine that could become complicated very quickly and presumably relies
    on the OS providing the signalling mechanisms for everything you might
    want to do - eg waiting for a socket connection (or whatever the decnet equivalent was).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastardlyHQ.org on Mon Jan 6 14:08:44 2025
    In article <vlg4mb$1hi6d$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >On Sun, 5 Jan 2025 21:09:55 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>>On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation >>>>on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible >>>>for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of >>>>a bunch of them at DEC. They would instinctively turn away from Unix ways >>>>of doing things, like forking multiple processes. So the systems they >>>>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >>>process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system
    architecture provides a mechanisms to signal completion; ASTs,
    mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    I imagine that could become complicated very quickly and presumably relies
    on the OS providing the signalling mechanisms for everything you might
    want to do - eg waiting for a socket connection (or whatever the decnet >equivalent was).

    It's a fairly common way to structure software even today. As I
    said, the OS provides asychronous notification mechanisms (ASTs)
    and IPC (mailboxes etc) for signaling operation completion.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@DastardlyHQ.org on Mon Jan 6 15:02:49 2025
    Muttley@DastardlyHQ.org writes:
    On Sun, 5 Jan 2025 21:09:55 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>>On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation >>>>on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible >>>>for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of >>>>a bunch of them at DEC. They would instinctively turn away from Unix ways >>>>of doing things, like forking multiple processes. So the systems they >>>>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >>>process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system
    architecture provides a mechanisms to signal completion; ASTs,
    mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    I imagine that could become complicated very quickly and presumably relies
    on the OS providing the signalling mechanisms for everything you might
    want to do - eg waiting for a socket connection (or whatever the decnet >equivalent was).

    Actually, it was straightfoward to use and rather elegent. You
    could build a nice asynchronous transfer algorithm just using AST's
    a and/or event flags.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastardlyHQ.org@21:1/5 to All on Mon Jan 6 14:21:48 2025
    On Mon, 6 Jan 2025 14:08:44 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlg4mb$1hi6d$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >>On Sun, 5 Jan 2025 21:09:55 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>>>On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation >>>>>on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible

    for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of

    a bunch of them at DEC. They would instinctively turn away from Unix ways >>>>>of doing things, like forking multiple processes. So the systems they >>>>>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >>>>process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system
    architecture provides a mechanisms to signal completion; ASTs,
    mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    I imagine that could become complicated very quickly and presumably relies >>on the OS providing the signalling mechanisms for everything you might
    want to do - eg waiting for a socket connection (or whatever the decnet >>equivalent was).

    It's a fairly common way to structure software even today. As I

    In Windows yes, which frankly is probably not a coincidence. Not so much
    in unix unless you're writing a GUI program.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@DastardlyHQ.org on Mon Jan 6 15:05:33 2025
    Muttley@DastardlyHQ.org writes:
    On Mon, 6 Jan 2025 14:08:44 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlg4mb$1hi6d$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >>>On Sun, 5 Jan 2025 21:09:55 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
    On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation >>>>>>on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible

    for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of

    a bunch of them at DEC. They would instinctively turn away from Unix ways >>>>>>of doing things, like forking multiple processes. So the systems they >>>>>>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >>>>>process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system >>>>architecture provides a mechanisms to signal completion; ASTs, >>>>mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    I imagine that could become complicated very quickly and presumably relies >>>on the OS providing the signalling mechanisms for everything you might >>>want to do - eg waiting for a socket connection (or whatever the decnet >>>equivalent was).

    It's a fairly common way to structure software even today. As I

    In Windows yes, which frankly is probably not a coincidence. Not so much
    in unix unless you're writing a GUI program.

    ASTs and unix signals have similar semantics. It's certainly possible to
    use, for example, SIGIO in a similar manner to the VMS AST, where the
    AST signals I/O completion and the AST handler initiates a subsequent operation.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastardlyHQ.org@21:1/5 to All on Mon Jan 6 15:55:19 2025
    On Mon, 06 Jan 2025 15:05:33 GMT
    scott@slp53.sl.home (Scott Lurndal) wibbled:
    Muttley@DastardlyHQ.org writes:
    In Windows yes, which frankly is probably not a coincidence. Not so much
    in unix unless you're writing a GUI program.

    ASTs and unix signals have similar semantics. It's certainly possible to >use, for example, SIGIO in a similar manner to the VMS AST, where the
    AST signals I/O completion and the AST handler initiates a subsequent >operation.

    Unix signals should only be used to set flags that are then read later. Doing anything complicated in a signal handler is asking for trouble as you have
    no idea where the program was when the signal occured and there can be all sorts of re-entrant issues or even deadlocks if using mutexes.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastardlyHQ.org on Mon Jan 6 15:22:51 2025
    In article <vlgots$1le5s$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >On Mon, 6 Jan 2025 14:08:44 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlg4mb$1hi6d$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >>>On Sun, 5 Jan 2025 21:09:55 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlecm0$1465i$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
    On Sat, 4 Jan 2025 22:13:05 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> gabbled:
    On Sat, 04 Jan 2025 08:31:05 -0300, Salvador Mirzo wrote:

    For instance, is there any Windows software that
    handles a TCP connection in an accept-fork-exec fashion?

    Almost certainly not. Because process creation is an expensive operation >>>>>>on Windows.

    Windows NT was masterminded by Dave Cutler, who was previously responsible

    for the VMS OS at his previous employer, DEC. He was a Unix-hater, part of

    a bunch of them at DEC. They would instinctively turn away from Unix ways >>>>>>of doing things, like forking multiple processes. So the systems they >>>>>>created did not encourage such techniques.

    Presumably VMS relied heavily on multithreading then like Windows or was a >>>>>process expected to everything itself sequentially?

    Many system services on VMS are asynchronous, and the system >>>>architecture provides a mechanisms to signal completion; ASTs, >>>>mailboxes, etc. Thus, many programs (not all) on VMS are
    written in a callback/closure style.

    I imagine that could become complicated very quickly and presumably relies >>>on the OS providing the signalling mechanisms for everything you might >>>want to do - eg waiting for a socket connection (or whatever the decnet >>>equivalent was).

    It's a fairly common way to structure software even today. As I

    In Windows yes, which frankly is probably not a coincidence. Not so much
    in unix unless you're writing a GUI program.

    Very much in Unix, actually. The kernel is highly asynchronous
    (it must be, to match the hardware), and has been since the
    early 1970s. Many user programs similarly.

    Historically, many systems have provided direct support for
    asynchronous programming on Unix. Going back to the early
    commerical Unix days, masscomp's real time Unix had ASTs, not
    signals, to support asynch IO directly from userspace. More
    recently, POSIX.1b and POSIX AIO are widely supported. Polling
    interfaces like kqueue and epoll, etc, exist largely to support
    multiplexing asynchronous tasks, though not using the callback
    model per se (one polls a set of e.g. file descriptors and
    dispatches explicitly based on their states as reported by the
    polling interface). Most recently, things like io_uring on
    Linux are designed specifically to support asynch IO in user
    programs.

    Granted, the Unix system interface is not particularly
    asynchronous-friendly, but that is by design. As Doug McIlroy
    put it,

    |The infrastructure had to be asynchronous. The whole point was
    |to surmount that difficult model and keep everyday programming
    |simple. User visibility of asynchrony was held to a minimum:
    |fork(), signal(), wait(). Signal() was there first and
    |foremost to support SIGKILL; it did not purport to provide a
    |sound basis for asynchronous IPC. (https://tuhs.org/mailman3/hyperkitty/list/tuhs@tuhs.org/message/IAAO2MRTMSX3C54YGTNOTIT4FEQA73IR/)

    This was fine for writing `cat` and `cp` etc, which were largely
    synchronous anyway. Less so for server-style programs or
    programs that had to multiplex data from many sources generally.

    This early decision to favor the comprehensibility of one class
    of program in the system call interface has had reverberations
    through time, leading to much complexity. This is one reason
    that, for example, the Go runtime has to jump through so many
    hoops to mux goroutines onto the underlying OS-provided thread
    abstraction; or that the implementation of async executors for
    Rust is hard (cf Tokio). In that same message referenced above,
    Doug continues:

    |The complexity of sigaction() is evidence that asynchrony
    |remains untamed 40 years on.

    This is unfair. It's evidence that grafting it onto an existing
    highly synchronous system interface that was simply not designed
    to accommodate it in the first place is very hard, even 50 years
    after the fact.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastardlyHQ.org@21:1/5 to All on Mon Jan 6 16:00:33 2025
    On Mon, 6 Jan 2025 15:22:51 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlgots$1le5s$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >>In Windows yes, which frankly is probably not a coincidence. Not so much
    in unix unless you're writing a GUI program.

    Very much in Unix, actually. The kernel is highly asynchronous
    (it must be, to match the hardware), and has been since the
    early 1970s. Many user programs similarly.

    Historically, many systems have provided direct support for
    asynchronous programming on Unix. Going back to the early
    commerical Unix days, masscomp's real time Unix had ASTs, not
    signals, to support asynch IO directly from userspace. More
    recently, POSIX.1b and POSIX AIO are widely supported. Polling
    interfaces like kqueue and epoll, etc, exist largely to support

    Multiplexing is not asychronous, its simply offloading status checking to
    the kernel. The program using is still very much sequential , at least at
    that point.

    Posix AIO is not asynch in the strict sense , its more "ok kernel, go do this and I'll check how you're doing later". Proper asynch where the program execution path gets bounced around between various callbacks is something
    else entirely.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@DastardlyHQ.org on Mon Jan 6 16:46:56 2025
    Muttley@DastardlyHQ.org writes:
    On Mon, 06 Jan 2025 15:05:33 GMT
    scott@slp53.sl.home (Scott Lurndal) wibbled:
    Muttley@DastardlyHQ.org writes:
    In Windows yes, which frankly is probably not a coincidence. Not so much >>>in unix unless you're writing a GUI program.

    ASTs and unix signals have similar semantics. It's certainly possible to >>use, for example, SIGIO in a similar manner to the VMS AST, where the
    AST signals I/O completion and the AST handler initiates a subsequent >>operation.

    Unix signals should only be used to set flags that are then read later.

    You're opinion is not widely shared. Note that the POSIX specification carefully notes which interfaces are not signal-safe.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastardlyHQ.org on Mon Jan 6 16:39:49 2025
    In article <vlgun1$1minf$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >On Mon, 6 Jan 2025 15:22:51 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) wibbled:
    In article <vlgots$1le5s$1@dont-email.me>, <Muttley@DastardlyHQ.org> wrote: >>>In Windows yes, which frankly is probably not a coincidence. Not so much >>>in unix unless you're writing a GUI program.

    Very much in Unix, actually. The kernel is highly asynchronous
    (it must be, to match the hardware), and has been since the
    early 1970s. Many user programs similarly.

    Historically, many systems have provided direct support for
    asynchronous programming on Unix. Going back to the early
    commerical Unix days, masscomp's real time Unix had ASTs, not
    signals, to support asynch IO directly from userspace. More
    recently, POSIX.1b and POSIX AIO are widely supported. Polling
    interfaces like kqueue and epoll, etc, exist largely to support

    Multiplexing is not asychronous, its simply offloading status checking to
    the kernel.

    Of course. It's a means to allow a program to respond to
    asynchronous events.

    The program using is still very much sequential , at least at
    that point.

    But the events are not. That's the point. This allows a
    program to initiate a non-blocking IO operation (like, say,
    establishing a TCP connection using the sockets API), go do
    something else, and check it's status later.

    Posix AIO is not asynch in the strict sense , its more "ok kernel, go do this >and I'll check how you're doing later". Proper asynch where the program >execution path gets bounced around between various callbacks is something >else entirely.

    The POSIX AIO interface allows the kernel to generate a signal
    to inform the program that an IO operation has completed, e.g.,
    by setting up the `aio_sigevent` and `SIGEV_SIGNAL`. It doesn't
    get much more asynchronous than that.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Kuyper@21:1/5 to Scott Lurndal on Mon Jan 6 12:42:48 2025
    On 1/6/25 11:46, Scott Lurndal wrote:
    Muttley@DastardlyHQ.org writes:
    ...
    Unix signals should only be used to set flags that are then read later.

    You're opinion is not widely shared. Note that the POSIX specification carefully notes which interfaces are not signal-safe.

    What precisely does "signal-safe" mean? As I understand it, it is
    supposed to be safe for a signal to interrupt standard library routines,
    but that it's not safe for a signal handler to call most of those
    functions. There's just a few exceptions, described below.

    The C standard says the following about signal handlers:
    "The functions in the standard library are not guaranteed to be
    reentrant and may modify objects with static or thread storage duration.
    239)" (7.1.4p4)
    Footnote 239 says "Thus, a signal handler cannot, in general, call
    standard library functions."

    "If the signal occurs other than as the result of calling the abort or
    raise function, the behavior is undefined if the signal handler refers
    to any object with static or thread storage duration that is not a
    lock-free atomic object and that is not declared with the constexpr storage-class specifier other than by assigning a value to an object
    declared as volatile sig_atomic_t, or the signal handler calls any
    function in the standard library other than
    — the abort function,
    — the _Exit function,
    — the quick_exit function,
    — the functions in <stdatomic.h> (except where explicitly stated
    otherwise) when the atomic arguments are lock-free,
    — the atomic_is_lock_free function with any atomic argument, or
    — the signal function with the first argument equal to the signal number corresponding to the signal that caused the invocation of the handler. Furthermore, if such a call to the signal function results in a SIG_ERR
    return, the object designated by errno has an indeterminate representation.310)" (7.14.1.1p5)
    Footnote 310 says "If any signal is generated by an asynchronous signal handler, the behavior is undefined."

    "If a signal occurs other than as the result of calling the abort or
    raise functions, the behavior is undefined if the signal handler reads
    or modifies an atomic object that has an indeterminate representation." (7.17.2p2)

    "If a signal occurs other than as the result of calling the abort or
    raise functions, the behavior is undefined if the signal handler calls
    the atomic_init generic function." (7.17.2.1p4)

    The POSIX standard claims that its version of <signal.h> conforms to the
    C standard, and as far as I can see, the POSIX standard doesn't say
    anything to define the behavior that is undefined by the C standard.

    Could you demonstrate how, within the above restrictions, a signal
    handler that doesn't cause the program to exit in one fashion or another
    could do anything useful other than "set flags that are read later"?
    I'm not saying it cannot be done. I claim no expertise in this kind of programming - I never needed to write signal handlers. However, the last
    time I considered the matter carefully (which was two or three versions
    of the C standard ago) I couldn't figure out how to do much more than
    that. At that time I did not consider how POSIX affects the issue, and I
    don't know enough about POSIX signals to evaluate that issue.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kalevi Kolttonen@21:1/5 to Muttley@dastardlyhq.org on Mon Jan 6 17:53:20 2025
    Muttley@dastardlyhq.org wrote:
    Unix signals should only be used to set flags that are then read later. Doing anything complicated in a signal handler is asking for trouble as you have
    no idea where the program was when the signal occured and there can be all sorts of re-entrant issues or even deadlocks if using mutexes.

    That is what I have learned, too, but I cannot remember the
    source. Maybe one of Richard Stevens' UNIX books.

    I am no expert, but I guess if you need to do async programming
    on UNIX/Linux userspace, your best is to use POSIX Threads.

    br,
    KK

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to jameskuyper@alumni.caltech.edu on Mon Jan 6 18:16:31 2025
    In article <vlh4mo$1nccc$1@dont-email.me>,
    James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
    On 1/6/25 11:46, Scott Lurndal wrote:
    Muttley@DastardlyHQ.org writes:
    ...
    Unix signals should only be used to set flags that are then read later.

    You're opinion is not widely shared. Note that the POSIX specification
    carefully notes which interfaces are not signal-safe.

    What precisely does "signal-safe" mean? As I understand it, it is
    supposed to be safe for a signal to interrupt standard library routines,
    but that it's not safe for a signal handler to call most of those
    functions. There's just a few exceptions, described below.

    From POSIX 2024, sectino 2.4 ("Signal Concepts"):

    |The following table defines a set of functions and
    |function-like macros that shall be async-signal-safe.
    |Therefore, applications can call them, without restriction,
    |from signal-catching functions. Note that, although there is
    |no restriction on the calls themselves, for certain functions
    |there are restrictions on subsequent behavior after the
    |function is called from a signal-catching function (see longjmp()). (https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04)

    (The table mentioned above includes over 200 functions.)

    The C standard says the following about signal handlers:
    "The functions in the standard library are not guaranteed to be
    reentrant and may modify objects with static or thread storage duration. >239)" (7.1.4p4)
    Footnote 239 says "Thus, a signal handler cannot, in general, call
    standard library functions."

    This is comp.unix.programmer, not comp.lang.c.

    [snip]

    "If a signal occurs other than as the result of calling the abort or
    raise functions, the behavior is undefined if the signal handler reads
    or modifies an atomic object that has an indeterminate representation." >(7.17.2p2)

    "If a signal occurs other than as the result of calling the abort or
    raise functions, the behavior is undefined if the signal handler calls
    the atomic_init generic function." (7.17.2.1p4)

    The POSIX standard claims that its version of <signal.h> conforms to the
    C standard, and as far as I can see, the POSIX standard doesn't say
    anything to define the behavior that is undefined by the C standard.

    This is factually incorrect.

    Could you demonstrate how, within the above restrictions, a signal
    handler that doesn't cause the program to exit in one fashion or another >could do anything useful other than "set flags that are read later"?

    Those restrictions don't apply in this context. But a trivial
    example:

    void
    reaper(int signo)
    {
    (void)signo;
    wait(NULL);
    }


    /* ... */
    signal(SIGCHLD, reaper);

    I'm not saying it cannot be done. I claim no expertise in this kind of >programming - I never needed to write signal handlers.

    Perhaps read up on the matter before commenting, then?

    However, the last
    time I considered the matter carefully (which was two or three versions
    of the C standard ago) I couldn't figure out how to do much more than
    that. At that time I did not consider how POSIX affects the issue, and I >don't know enough about POSIX signals to evaluate that issue.

    In strict C, this is correct. But while POSIX includes ISO C as
    a subset, it extends allowable behavior in lots of places to
    both standardize the behavior of existing programs as well as
    make it possible to write useful programs on Unix-style systems.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to James Kuyper on Mon Jan 6 18:52:28 2025
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 1/6/25 11:46, Scott Lurndal wrote:
    Muttley@DastardlyHQ.org writes:
    ...
    Unix signals should only be used to set flags that are then read later.

    You're opinion is not widely shared. Note that the POSIX specification
    carefully notes which interfaces are not signal-safe.


    Could you demonstrate how, within the above restrictions, a signal
    handler that doesn't cause the program to exit in one fashion or another >could do anything useful other than "set flags that are read later"?
    I'm not saying it cannot be done. I claim no expertise in this kind of >programming - I never needed to write signal handlers. However, the last
    time I considered the matter carefully (which was two or three versions
    of the C standard ago) I couldn't figure out how to do much more than
    that. At that time I did not consider how POSIX affects the issue, and I >don't know enough about POSIX signals to evaluate that issue.

    Augmenting Dan's well-written response, I'd point out that those
    POSIX interfaces (many of which are system calls, not library
    functions) are designed to work with signals. One common
    technique is to call longjmp() from within a SIGINT handler;
    all the application must do is mask the signal if/when executing
    in a non-async-signal-safe critical section. Note that a signal
    (with a few exceptions) will not interrupt a system call, and when
    it does, the system call returns EINTR to the caller without any
    other caller-visible side effects (either the system call fully
    completes before the signal is delivered, or it has no effect).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to James Kuyper on Mon Jan 6 18:24:24 2025
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 1/6/25 11:46, Scott Lurndal wrote:
    Muttley@DastardlyHQ.org writes:
    ...
    Unix signals should only be used to set flags that are then read later.

    You're opinion is not widely shared. Note that the POSIX specification
    carefully notes which interfaces are not signal-safe.

    What precisely does "signal-safe" mean?

    The UNIX standard has meanwhile started to contradict itself on this
    topic because of the apparent attempt to follow the (pretty silly) C++
    memory model incorporated into C for no particular reason. But the
    relevant part of the UNIX definition (still part of the current
    definition) used to be

    In the presence of signals, all functions defined by this volume
    of POSIX.1-2024 shall behave as defined when called from or
    interrupted by a signal-catching function, with the exception
    that when a signal interrupts an unsafe function or
    function-like macro, or equivalent (such as the processing
    equivalent to exit() performed after a return from the initial
    call to main()), and the signal-catching function calls an
    unsafe function or function-like macro, the behavior is
    undefined.

    This text is below the list of async-signal safe interfaces. It
    contradicts the

    the behavior is undefined if:

    [...]

    The signal handler calls any function or function-like macro
    defined in this standard other than one of the functions and
    macros specified below as being async-signal-safe.

    immediately above it.

    https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04

    When ignoring the apparent attempt at making signals really impossible
    to use, "async signal-safe" is really quite simple: Any handler can do
    anything provided it doesn't invoke some kind of not async signal safe interface. A handler which didn't interrupt an interface that's not
    async signal safe can anything, including calling unsafe functions.

    A usual way to achieve the latter is to keep signals blocked except when calling an async signal safe functions, eg, pselect, ppoll or
    sigsuspend.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Mon Jan 6 20:26:15 2025
    On Mon, 6 Jan 2025 14:21:48 -0000 (UTC), Muttley wrote:

    Not so much in unix unless you're writing a GUI program.

    In *nix, select/poll works well when the performance bottleneck resides in
    the I/O. async/await lets you linearize the logic of your handlers for
    easier comprehension, instead of breaking them up into separate calback
    stages.

    async/await is also useful in GUI programs, for the same reason.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Kalevi Kolttonen on Mon Jan 6 20:28:43 2025
    On Mon, 6 Jan 2025 17:53:20 -0000 (UTC), Kalevi Kolttonen wrote:

    I am no expert, but I guess if you need to do async programming on
    UNIX/Linux userspace, your best is to use POSIX Threads.

    Threads are something you normally want to avoid, unless CPU usage is the bottleneck in your application.

    In the case where the limiting factor is I/O or network bandwidth, or a
    GUI app waiting for user input, then async/await is a more convenient
    paradigm.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Lawrence D'Oliveiro on Mon Jan 6 20:36:47 2025
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Mon, 6 Jan 2025 17:53:20 -0000 (UTC), Kalevi Kolttonen wrote:

    I am no expert, but I guess if you need to do async programming on
    UNIX/Linux userspace, your best is to use POSIX Threads.

    Threads are something you normally want to avoid, unless CPU usage is the >bottleneck in your application.

    Complete and utter nonsense.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to Scott Lurndal on Mon Jan 6 20:38:28 2025
    In article <z9XeP.3$TgDc.2@fx38.iad>, Scott Lurndal <slp53@pacbell.net> wrote: >Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Mon, 6 Jan 2025 17:53:20 -0000 (UTC), Kalevi Kolttonen wrote:

    I am no expert, but I guess if you need to do async programming on
    UNIX/Linux userspace, your best is to use POSIX Threads.

    Threads are something you normally want to avoid, unless CPU usage is the >>bottleneck in your application.

    Complete and utter nonsense.

    As you would expect, cosidering the source.

    --
    Just for a change of pace, this sig is *not* an obscure reference to comp.lang.c...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Mon Jan 6 20:27:15 2025
    On Mon, 6 Jan 2025 16:00:33 -0000 (UTC), Muttley wrote:

    Posix AIO is not asynch in the strict sense , its more "ok kernel, go do
    this and I'll check how you're doing later".

    POSIX has “real-time signals”, which are very similar to VMS ASTs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Tue Jan 7 00:49:32 2025
    Kalevi Kolttonen, dans le message <vlh5ag$1nruu$1@dont-email.me>, a
    Θcritá:
    I am no expert, but I guess if you need to do async programming
    on UNIX/Linux userspace, your best is to use POSIX Threads.

    Very common misconception. The communication mechanisms between POSIX
    threads and Unix I/O are completely alien to each-other: it is not possible
    to poll() on a thread condition, nor is it it possible to set up a condition
    to be woken by data on a file descriptor. As a result, anybody who tries to
    use threads to solve problems of I/O concurrency ends up having to implement
    a poll() or equivalent loop in each thread, defeating the purpose.

    POSIX threads are good to improve on computation concurrency, but they do
    not make I/O concurrency simpler, quite the opposite.

    The same might not be true for other kinds of threads.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Nicolas George on Tue Jan 7 02:14:11 2025
    On 07 Jan 2025 00:49:32 GMT, Nicolas George wrote:

    The communication mechanisms between POSIX
    threads and Unix I/O are completely alien to each-other: it is not
    possible to poll() on a thread condition, nor is it it possible to set
    up a condition to be woken by data on a file descriptor.

    Linux offers signalfd, so you can indeed use poll(2) in a thread to be
    woken up by any file descriptor, including a signal one (and that includes POSIX real-time signals).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)