Page MenuHomeFreeBSD

Add sig_intr().
ClosedPublic

Authored by kib on Oct 1 2020, 3:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jan 25, 7:56 PM
Unknown Object (File)
Dec 9 2024, 8:30 AM
Unknown Object (File)
Nov 28 2024, 8:15 AM
Unknown Object (File)
Sep 23 2024, 11:48 AM
Unknown Object (File)
Sep 23 2024, 7:00 AM
Unknown Object (File)
Sep 22 2024, 9:21 PM
Unknown Object (File)
Sep 16 2024, 12:18 PM
Unknown Object (File)
Sep 5 2024, 6:43 PM

Details

Summary

First, refactor sleepq_catch_signals() with the following goals:

  • extract suspension check into sig_ast_checksusp() helper.
  • extract signal check and calculation of the interruption errno into sig_ast_needsigchk() helper.
  • improve control flow, to handle ret == 0 (can sleep) and ret != 0 (interrupted) only once, by separating checking code into sleepq_check_ast_sq_locked(), which return value is interpreted only once.

Second, add sig_intr() generic-purpose function, which gives the answer would the thread sleep according to current state of signals and suspensions. Of course the answer is racy and allows for false-negatives (no sleep when signal is delivered after process lock is dropped). Also the answer might change due to signal rescheduling among threads in multi-threaded process. Still it is the best approximation I can provide, to answering the question was the thread interrupted.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Oct 1 2020, 3:33 PM

What's the difference between sig_intr and issignal?

What's the difference between sig_intr and issignal?

At the high-level, sig_intr() just answers the question would a sleep interrupted if thread decided to sleep. issignal() does something different, it _selects_ a signal to handle (looking both into the thread and process signal queues), if any, removes it from the queue, notifies debugger, drops signals that are not actionable, and does a lot of other stuff all in preparation for final handling. In other words, caller can only use issignal (or cursig) if the caller is prepared to finish processing the signal returned by issignal.

Ok. Could you please add that information to the signal.9 man page?

Ok. Could you please add that information to the signal.9 man page?

This would be a separate project. In fact, the description of issignal() is mostly fine, perhaps the long enumeration of locks is not too useful. But other stuff there is completely outdated, starting with PS_NEEDSIGCHK and failure to note that cursig() is a wrapper around issignal().

The fact that other stuff in that man page is out of date should not be a blocker to documenting the newly-added function.

This revision is now accepted and ready to land.Oct 3 2020, 4:42 PM

I ran all of the stress2 tests with D26628.77727.
No problems seen.

This revision was automatically updated to reflect the committed changes.