erik quanstrom
2011-11-21 15:08:18 UTC
sysrfork() does *not* do a procsave before forking. thus the
floating point registers in the new process are just going to
be a copy of whatever was last saved, and perhaps nothing.
on my atom system (but not some others), this attached
program does fault. i wrote a bit of it in assembler to control
what was in F0. the c compiler wasn't keeping things in a
register.
have i missed something or do we need a procsave() in fork?
- erik
---
sed 's/.//' >fp.c <<'//GO.SYSIN DD fp.c'
-#include <u.h>
-#include <libc.h>
-
-char *theformat = "%g\n";
-
-void
-main(void)
-{
- extern void dofp(void);
-
- dofp();
-}
//GO.SYSIN DD fp.c
echo myfp.s
sed 's/.//' >myfp.s <<'//GO.SYSIN DD myfp.s'
-TEXT dofp(SB), $0
- SUBL $12, SP
- FLD1
- CALL fork(SB)
-
- MOVL $2000, AX
- MOVL AX, 0x0(SP)
- CALL sleep(SB)
-
- MOVL theformat(SB), AX
- MOVL AX, 0x0(SP)
- FMOVDP F0,0x4(SP)
- CALL print(SB)
- ADDL $12, SP
- RET
//GO.SYSIN DD myfp.s
floating point registers in the new process are just going to
be a copy of whatever was last saved, and perhaps nothing.
on my atom system (but not some others), this attached
program does fault. i wrote a bit of it in assembler to control
what was in F0. the c compiler wasn't keeping things in a
register.
have i missed something or do we need a procsave() in fork?
- erik
---
sed 's/.//' >fp.c <<'//GO.SYSIN DD fp.c'
-#include <u.h>
-#include <libc.h>
-
-char *theformat = "%g\n";
-
-void
-main(void)
-{
- extern void dofp(void);
-
- dofp();
-}
//GO.SYSIN DD fp.c
echo myfp.s
sed 's/.//' >myfp.s <<'//GO.SYSIN DD myfp.s'
-TEXT dofp(SB), $0
- SUBL $12, SP
- FLD1
- CALL fork(SB)
-
- MOVL $2000, AX
- MOVL AX, 0x0(SP)
- CALL sleep(SB)
-
- MOVL theformat(SB), AX
- MOVL AX, 0x0(SP)
- FMOVDP F0,0x4(SP)
- CALL print(SB)
- ADDL $12, SP
- RET
//GO.SYSIN DD myfp.s