At 2023-06-14T02:36:03+0700, Robert Elz via austin-group-l at The Open Group 
wrote:
>     Date:        Tue, 13 Jun 2023 09:29:52 +0000
>     From:        Austin Group Bug Tracker <[email protected]>
>     Message-ID:  <[email protected]>
> 
>   | You don't seem to have considered the case where the thread that
>   | receives the signal is currently running, and is executing user
>   | code.
> 
> No, that's one of the shortish pending cases.
> 
>   | Then there is nothing to delay the delivery - it can happen
>   | immediately after generation,
> 
> No, it can't in that case, it needs to wait until the process enters
> the kernel for some reason.   Typically if a signal is delivered to a
> process while it is in application mode, it will be the result of a
> kill() from another process running on a different CPU (anything the
> process does to itself, including traps, result in the process being
> in the kernel when the signal is delivered - the kernel side of the
> process is posting the signal to itself).   When that happens, the
> other CPU (the one running the application) needs to be notified that
> there's an event it needs to process, which will result in that
> process being (temporarily) suspended and the kernel taking over.

This seems to me to assume too much about kernel design.  A process
could be preempted (signalled) by being frozen as-is: its memory image,
stack(s), and registers saved.  If the kernel elected to revive it for
signal delivery--it would not for un-handleable signals like POSIX KILL
or QUIT--then the kernel could start it up again, possibly on a
different core, with its memory image and stacks restored, a new stack
frame (possibly on an alternate stack) holding the former register
values (possibly with other housekeeping information), and the program
counter set to the entry point for the appropriate signal handler
(possibly with supplemental information about the signal's cause or
process state at interruption in registers).

I apologize for the possibly academic recapitulation of multitasking,
but the key point is that the foregoing model does not require the
process to "enter the kernel" to service the signal.

There's arguably not much difference between your presentation and mine;
in mine, something special and kernelly _might_ need to happen when
returning from the signal handler, but off the top of my head that
doesn't need to be done in kernel mode either; your program runtime
support library can have a helper procedure that resets the registers
(including the program counter) from the temporary stack frame mentioned
above.  All the signal handler has to do is jump to this helper.  No
mode switch is necessary.

> When that is done (which may be immediate, or may be later if the cpu
> in consideration switches to some other process) and the kernel is
> returning control to the application, is when the signal is delivered.
> In the interim period (which may be very short, or may be lengthy (in
> computer terms anyway)) the signal is pending.   But not blocked.  (Of
> course, that is assuming it wasn't being blocked).

I guess the question from the POSIX perspective is whether a signal can
be pending if a process cannot observe it to be.  In the scenario I
present above, I don't think it is.  Checking the 2.1 draft of Issue 8,
the "ps" command admits a "status" field for process state but
prescribes no values.  That's good.  I surmise, then, that "signal
pendingness" is not a trait that POSIX needs to define, or even employ.
The standard should avoid the term if using it--even just for expository
purposes--is going to provoke controversy among highly seasoned Unix
kernel engineers who are accustomed to using it with a more
implementation-specific meaning.

Apologies in advance if I said something stupid.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
    • Re: [10... Geoff Clare via austin-group-l at The Open Group
    • Re: [10... Robert Elz via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • Re: [1003.1(... Robert Elz via austin-group-l at The Open Group
    • Re: [10... G. Branden Robinson via austin-group-l at The Open Group
    • Re: [10... Robert Elz via austin-group-l at The Open Group
      • Re:... G. Branden Robinson via austin-group-l at The Open Group
      • Re:... Robert Elz via austin-group-l at The Open Group
    • Re: [10... Scott Lurndal via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group

Reply via email to