Messages in this thread |  | | Date | Fri, 17 Jan 1997 15:25:24 +0100 (MET) | From | "Peter.Vaneynde" <> | Subject | strange interaction between signal and used_math |
| |
If you run the included program you'll see that he FPU control word gets reset in a signal handler. The cause of this is the fninit in math_state_restore(void) in arch/i386/kernel/traps.c. It seams that used_math isn't set for the signal handler of a process that has set the cw.
I'm unsure what the normal behavior is, but in CMUCL there are no special cases in the handler (except now for Linux).
Should Linus rubber stamp the current behavior or should the cw be restored for the signal handler?
if(current->used_math) __asm__("frstor %0": :"m" (current->tss.i387)); else { /* * Our first FPU usage, clean the chip. */ __asm__("fninit"); This causes the signal handler to lose the cw... current->used_math = 1; }
Groetjes, Peter
-- It's logic Jim, but not as we know it. finger s950045@hipe.uia.ac.be for pgp public key. Version: 3.12 GS/CS/L/C d->? s+:++>+@ a-- C++(+++)>$ ULOS++>++++$ P+>++++ L+++>++++ E>++ W+(--) U++>+++ o>+ K? w--- O>+@ M-? V? PS++ PE(--) Y+ PGP+>++ t++>+++ 5++ X++>+++ R tv b+++>++++ DI++ D++@ G+>++ e++>++++ h!>+ r-@ y>+++**@ #include <stdio.h> #include <unistd.h> #include <math.h> #include <signal.h> #include <i386/fpu_control.h>
int in_handler=0;
void handler(void) { in_handler = __getfpucw(); }
int main(int argc,char *argv[]) { __setfpucw(0x1370); signal(SIGALRM,&handler); alarm(5); printf("alarm in 5 secs...\n"); for(;;) { sleep(2); printf("main: %x handler: %x\n",__getfpucw(),in_handler); } }
|  |