gcc signals & Exec signals

gcc signals & Exec signals

Post by Erik van Roo » Tue, 08 Dec 1992 23:33:21



  I am writing a program which uses messageports to communicate with
other programs. Now I'm switching to gcc, but I have a few problems
with gcc. The program needs to wait for message-arrivel on the ports,
but that waiting must be interruptable by a SIGALRM arrival. I tried
a few things, but I seem to be doing something wrong, `cos I can't get
it working.

I installed a handler for SIGMSG
I installed a handler for SIGALRM
then I do :
    sigpause(0);        /* wait until we are interrupted */

But sigpause is not interrupted by arrival of a message :(

Can someone tell me what I'm doing wrong ?


--
 Erik van Roode                 Educators keep writing simpler textbooks
 University of Amsterdam        hoping that they will encourage underachievers,
 Dept. of Computer Science      with the result that bright kids now don't

 
 
 

gcc signals & Exec signals

Post by Markus Wi » Wed, 09 Dec 1992 02:22:10



Quote:>I installed a handler for SIGMSG
>I installed a handler for SIGALRM
>then I do :
>    sigpause(0);    /* wait until we are interrupted */

>But sigpause is not interrupted by arrival of a message :(

Is the SIGMSG handler you installed invoked once?

Does your SIGALRM handler some regular task (like incrementing counters,
blinking a cursor, etc.), or is it invoked as a timeout facility? The
interesting question is whether the handler is left with longjmp() or whether
it returns normally, thus continuing the program where it was interrupted.

If the SIGALRM handler doesn't longjmp(), the easiest thing to do is to
just ignore that it exists. You can't cause any harm to an interrupted
WaitPort() or Wait(), as signals save and restore the Forbid() and Disable()
counters before/after executing a signal handler. If it does longjmp(), you
can get around the problem of fussing with the message queue by using
this approach:

        if (setjmp (jmpbuf))
          {
            /* was interrupted... */
            ....
          }
        Wait ( <signalmask of your msg port> );

        omask = sigsetmask (~0);
        while (msg = GetMsg (...))
          {
            ...
          }
        sigsetmask (omask);

Wait(), as a special exception to system calls, may be interruted (since
as mentioned above, Forbid()/Disable() counters are preserved by the
signal dispatcher). Important note though: if you do such things, *never*
use _longjmp() to leave a signal handler, only longjmp(), or those counters
are *not* reset!

--

Vital papers will demonstrate their vitality by spontaneously moving
from where you left them to where you can't find them.

 
 
 

gcc signals & Exec signals

Post by Brett Wu » Thu, 10 Dec 1992 12:43:45



>  I am writing a program which uses messageports to communicate with
>other programs. Now I'm switching to gcc, but I have a few problems
>with gcc. The program needs to wait for message-arrivel on the ports,
>but that waiting must be interruptable by a SIGALRM arrival. I tried
>a few things, but I seem to be doing something wrong, `cos I can't get
>it working.

>I installed a handler for SIGMSG
>I installed a handler for SIGALRM
>then I do :
>    sigpause(0);    /* wait until we are interrupted */

>But sigpause is not interrupted by arrival of a message :(

>Can someone tell me what I'm doing wrong ?



I've never used gcc.

At a guess, I'd say you have to figure out which Exec Signal bits
are being used by gcc's signal, and use them with the ones from
your Exec Message Port(s) in an Exec Wait().

Worst case, you may have to write an Exec Exception handler for
_your_ Exec Signals.  That's quite difficult.  

Or you could split it into two processes.  One does waiting for
Exec Signals, one does waiting for gcc signals.  The slave
signals the master using the master's mechanism whenever something
happens.

Good luck,
--

U302, 3510 44St SW, Calgary, Alberta, T3E 3R9, CANADA  Tel: +1 403 242-0848

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.0

mQCNAir+Xh0AAAEEALLCqKl8T/5b81Wn+pftOjR2HEY0f0z1bw6jXnANGqGDEBSc
NTTcxUQX4ryOOIr+n8GmqeWOaFQ8kiZxDUR1v2detA3BuAGQt+ixg61T1bV3poz+
eG5YbRbsYFLCep3eRn4BXV0mZECz3jIpKN0Y/j9DcVZWL+VyeKudBjgjJ22BAAUR
tCNCcmV0dCBXdXRoIDx3dXRoQGNhc3Ryb3YuY3VjLmFiLmNhPrQeQnJldHQgV3V0
aCA8d3V0aEBjYXN0cm92LlVVQ1A+
=zvTV
-----END PGP PUBLIC KEY BLOCK-----
[Pls ignore if you don't have PGP secure-mail program.  See sci.crypt.]

 
 
 

gcc signals & Exec signals

Post by Markus Wi » Fri, 11 Dec 1992 02:35:16




>>  I am writing a program which uses messageports to communicate with
>>other programs. Now I'm switching to gcc, but I have a few problems
>>with gcc. The program needs to wait for message-arrivel on the ports,
>>but that waiting must be interruptable by a SIGALRM arrival. I tried
>At a guess, I'd say you have to figure out which Exec Signal bits
>are being used by gcc's signal, and use them with the ones from
>your Exec Message Port(s) in an Exec Wait().

ixemul signals are not implemented with Exec signals, thus you can't Wait()
for them.

-Markus

--

Vital papers will demonstrate their vitality by spontaneously moving
from where you left them to where you can't find them.

 
 
 

1. Audio signal amp to 6 volt signal?

Hello, I am an electronics moron.  I am shortly receiving a kit in the mail
for spirographing my laser.  The catalog states that it requires a 6 volt
control signal and that I can use an audio signal.  I would like to use the
audio signal from my Amiga, but I am aware that this is nowhere near 6 volts.
So the question is, what kind of crud do I need to amplify the Amiga's audio
signal to 6 volts?
--
                       "Who loves, raves." - Lord Byron

DISCLAIMER: My writings have NOTHING to do with my employer.  Keep it that way.

2. Displaying BMP files

3. AmiTCP sockets and exec signals

4. error with 63 min CDR HI SPACE in PHILIPS 2600

5. WTB: AppleWorks 1.3 in box

6. gcc-2.4.5 kill() and signal() troubles

7. FPL Email

8. GCC signal handling bug

9. Arrival of the new Intel BX chipset signals massive leap ahead in bus technology...

10. Sharing a SCSI bus, and SCSI reset signals

11. Amiga Video signal

12. a2000 video port c4 signal