home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / os2 / programm / 4779 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  3.6 KB

  1. Path: sparky!uunet!wupost!waikato.ac.nz!aukuni.ac.nz!ecmtwhk
  2. Newsgroups: comp.os.os2.programmer
  3. Subject: Re: Division by 0 crashes OS2/2.0
  4. Message-ID: <1992Sep7.080210.3379@ccu1.aukuni.ac.nz>
  5. From: ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig)
  6. Date: Mon, 7 Sep 1992 08:02:10 GMT
  7. References: <1992Sep2.163508.17347@tc.cornell.edu>
  8. Organization: University of Auckland, New Zealand.
  9. Lines: 69
  10.  
  11. bai@msiadmin.cit.cornell.edu (Dov Bai-MSI Visitor) writes:
  12.  
  13. >The following short program compiled with MS-FORTRAN 5.0 with 
  14. >coprocessor crashes OS2 Ver. 2 on my machine:
  15.  
  16. [division by zero example deleted]
  17.  
  18. I think you have encountered a problem described in the PC-Clone
  19. UNIX Hardware Buyer's Guide (see news.groups for it).
  20.  
  21. Here's the relevant part:
  22.  
  23. Archive-name: pc-unix/hardware
  24. Last-update: Wed Aug 12 13:15:22 1992
  25. Version: 6.0
  26.  
  27. [...]
  28.  
  29. Finally, beware the infamous FP exception bug!  Some motherboards fail to
  30. handle floating point exceptions correctly; instead of generating a SIGFPE they
  31. lock up. The following fragment of C code will reproduce the problem:
  32.  
  33.     double d;
  34.  
  35.     d = 0.0;
  36.     d = 1.0 / d;    /* floating divide by zero should yield SIGFPE */
  37.  
  38. John R. Levine <johnl@iecc.cambridge.ma.us> explains: "The difficulty stems
  39. from the fact that there are two ways to handle floating exceptions on a 486,
  40. the right way and the PC way.  What the 486 wants to do is to generate an
  41. interupt 16 when there is a floating point error, all entirely internal to the
  42. CPU.  This has been the native way to handle floating point interrupts since
  43. the 286/287.  The 286/287 and 386/387 each have a dedicated ERROR pin that the
  44. FPU uses to tell the CPU that it's time for an error interrupt.
  45.  
  46. Unfortunately, the 8086/8087 handled interrupts differently.  The error pin on
  47. the 8087 was wired to the 8259A interrupt controller, the same interrupt
  48. controller that handled keyboard, disk, clock, etc.  interrupts.  The PC/AT
  49. enshrined IRQ 13 as the one for floating interrupts.  (The details of this are
  50. a little hazy to me, since the XT didn't have IRQ 13 tied to an 8259A, so the
  51. AT must have at least changed the interrupt number.)  PC designs have generally
  52. wired the 287 or 387 ERROR pin to the 8259A, not to the ERROR pin on the CPU,
  53. or at best had some poorly documented way to switch between the two interrupt
  54. methods.
  55.  
  56. In the interest of backward compatibility, the 486 has a mode bit that says not
  57. to handle FP exceptions automatically, but rather to freeze the FPU and send a
  58. signal on the FERR pin, which is usually tied to an 8259A which then feeds the
  59. interrupt back as IRQ 13.  There is some extra complication involved here
  60. because the FPU has to stay frozen until the interrupt is accepted so the CPU
  61. can go back and look at the FPU's state.  Early 386/25 chips had a bug that
  62. would sometimes freeze up on a floating point interrupt and you had to get a
  63. kludge socket with a PAL that fixed the timing glitch that provoked the bug.
  64.  
  65. So as likely as not, the motherboard hardware that runs FERR out and back isn't
  66. working correctly.  It's not surprising, few DOS users take floating point
  67. seriously enough to notice whether the interrupts are working right."
  68.  
  69. When you specify a system, make clear to your vendor that the motherboard must
  70. handle float exceptions properly.  Test your motherboard's handling of
  71. divide-by-zero; if it doesn't work, press your vendor to replace it *and
  72. send me email*!  Only by publishing a list of boards known bad can we
  73. protect ourselves and pressure vendors to fix this problem.
  74.  
  75. [...]
  76. -- 
  77. Thomas Koenig, ecmtwhk@ccu1.aukuni.ac.nz, ib09@rz.uni-karlsruhe.de
  78. The joy of engineering is to find a straight line on a double logarithmic
  79. diagram.
  80.