[M3devel] chosing SIG_SUSPEND?

Jay jay.krell at cornell.edu
Thu Jan 22 02:34:38 CET 2009


The code is now:
 
 
#define SIG_SUSPEND ThreadPThreadC_SIG_SUSPEND
 
/* expected values for compat, if compat matters:
    Solaris: 17 (at least 32bit SPARC?)
    Cygwin: 19 -- er, but maybe that's wrong
    Linux: 64
    FreeBSD: 31
    OpenBSD: 31
    HPUX: 44
  Look at the history of Usignal and RTMachine to find more values.
  There was RTMachine.SIG_SUSPEND and SIG was aliased to it.
  Both SIG and SIG_SUSPEND were only defined for systems using pthreads.
  SIG was shorthand.
*/
#if defined(__APPLE__)
const int SIG_SUSPEND = 0;
#elif defined(__sun) || defined(__CYGWIN__) || defined(__FreeBSD__)
const int SIG_SUSPEND = SIGUSR2;
#elif defined(__linux)
const int SIG_SUSPEND = NSIG - 1;
#elif defined(SIGRTMAX)
/* This might be a function call, in which case try _SIGRTMAX or initializing it somewhere. */
const int SIG_SUSPEND = SIGRTMAX;
#elif defined(SIGUSR2)
const int SIG_SUSPEND = SIGUSR2;
#else
#error Unable to determine SIG_SUSPEND.
#endif

Compatible but perhaps not ideal.
It'll automatically port to "something" now, less per-machine work.
  The #ifdefs are overly broad, since __sun and __FreeBSD__ will cover more than just older platforms but also newer ones -- need to check processor.
"SIG" is gone, it was private and I think merely "shorthand", not important. Uses say SIG_SUSPEND.
SIG_SUSPEND gone from RTMachine.i3 and in ThreadPThreadC.{c,i3}
 
 - Jay


----------------------------------------
> From: hosking at cs.purdue.edu
> To: jay.krell at cornell.edu
> Date: Wed, 21 Jan 2009 09:42:38 -0500
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] chosing SIG_SUSPEND?
>
> Yes, we want a signal no-one else is using to stop the threads.
>
> On 21 Jan 2009, at 08:37, Jay wrote:
>
>>
>> Solaris at least currently has SIGRTMAX.
>> I want to switch RTSignalC.c to "something" here.
>> I can preserve compat, like
>>
>> #ifdef __sun
>> SIGUSR2
>> #else..
>>
>> or..?
>>
>> I could do
>> #ifdef SIGUSR2
>> #define SIG_SUSPEND SIGUSR2
>> #elif defined(SIGRTMAX)
>> #define SIG_SUSPEND SIGRTMAX
>> #else
>> #error
>> #endif
>>
>> I'll go with a compatible version for now and you can change it if
>> you want.
>> I'll test on Linux/x86, FreeBSD (AMD64, but hopefully there is gcc -
>> m32),
>> Linux/PPC, Solaris, Cygwin, Darwin/PPC (uh, actually, no, Darwin isn't
>> really relevant, but I'll make sure the result does what is intended.)
>>
>> It looks like SIGRTMAX is a function call on Solaris.
>>
>> This stuff is like broken, right?
>> I mean, there's a small number of signals and there's no arbitration.
>> People just take them over and hope nobody else cares.
>>
>>
>> There's no way to just queue a function call to a thread, in
>> portable/general?
>> Windows has QueueUserAPC or SuspendThread (SuspendThread is dangerous,
>> thread could be doing anything), QueueUserAPC only interrupts at
>> certain times.
>>
>>
>> - Jay
>>
>>
>> ----------------------------------------
>>> From: hosking at cs.purdue.edu
>>> To: jay.krell at cornell.edu
>>> Date: Wed, 21 Jan 2009 03:42:01 +1100
>>> CC: m3devel at elegosoft.com
>>> Subject: Re: [M3devel] chosing SIG_SUSPEND?
>>>
>>> Choose SIGRTMAX first if defined, then SIGUSR2. I don't thing NSIG-1
>>> is reliable, but just works on some systems.
>>>
>>> On 21 Jan 2009, at 01:12, Jay wrote:
>>>
>>>>
>>>> What is the algorithm for chosing SIG_SUSPEND?
>>>>
>>>> Something like:
>>>>
>>>> #include
>>>>
>>>> #ifdef __APPLE__
>>>> /* nothing -- SIG_SUSPEND not used */
>>>> #elif defined(NSIG)
>>>> #define SIG_SUSPEND (NSIG - 1)
>>>> #elif defined(_NSIG)
>>>> #define SIG_SUSPEND (_NSIG - 1)
>>>> #elif defined(SIGRTMAX)
>>>> #define SIG_SUSPEND SIGRTMAX
>>>> #else
>>>> #define SIG_SUSPEND SIGUSR2
>>>> #endif
>>>>
>>>> ?
>>>>
>>>> Whatever it is, I think it should be in RTSignalC.c.
>>>>
>>>> - Jay
>>>
>


More information about the M3devel mailing list