home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 9024 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  2.5 KB

  1. Xref: sparky comp.os.msdos.programmer:9024 comp.os.msdos.misc:5032
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
  3. Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
  4. Subject: Re: Why ms-dos is non reentrant
  5. Message-ID: <1992Sep2.174517.2209@brandonu.ca>
  6. From: dueck@brandonu.ca
  7. Date: 2 Sep 92 17:45:17 CST
  8. References: <92245.122042A10742@TRMETU.BITNET>
  9. Organization: Brandon University, Brandon, Manitoba, Canada
  10. Lines: 62
  11.  
  12. In article <92245.122042A10742@TRMETU.BITNET>, Pinar Aydemir <A10742@TRMETU.BITNET> writes:
  13. > I almost hear everyday that msdos is non-reentrant.
  14. > It is non re-entrant so dont call a dos funcion from a Interrupt Service
  15. > Routine.
  16. > Since It is non reentrant, bla bla bla.
  17. > I looked at some books about OS, and the definition of reentrancy is
  18. > given as being unmodified (pure) code.So, what makes msdos non reentrant ?
  19. > Any information  is appreciated.
  20. > -Yasemin
  21.  
  22. That definition is not quite correct. Pure code just means that you don't
  23. modify code on the fly.
  24.  
  25. Reentrance requires the notion of a process: code + data. The code
  26. remains constant, but the data is different for each occurence of a process.
  27.  
  28. For example:
  29.    x dw 0
  30.  
  31. incrax:
  32.    mov x, ax
  33.    add x, 1
  34.    mov ax, x
  35.    ret
  36.  
  37. is not re-entrant, but
  38.  
  39. incrax:
  40.    push bp
  41.    mov  bp,sp
  42.    sub  sp, 2
  43.    mov  [bp-2], ax
  44.    add  [bp-2], 1
  45.    mov  ax, [bp-2]
  46.    mov    sp, bp
  47.    ret
  48.  
  49. is re-entrant. The difference? We have to consider that an interrupt handler
  50. can be invoked at any time (asynchronous), that it may call the incrax routine, and that
  51. at the time of the interrupt, the CPU was executiong somewhere in incrax
  52. (what I call a synchronous execution).
  53.  
  54. In the first example, an interrupt handler invoked asynchronously that 
  55. calls incrax will modify location x, thereby causing an incorrect
  56. result from the synchronous call to incrax,
  57.  
  58. An interrupt handler that calls incrax in the second example will not
  59. clobber location x, since the data areas used by the code is specific 
  60. to an instance of a thread of control. Thus the asynchronous execution
  61. cannot interfere with the synchronous execution.
  62.  
  63. In the case of DOS, the state of a system call is stored in fixed locations.
  64. A system call made from within an interrupt handler modifies the state
  65. represented by those locations. So when the interrupt completes, and
  66. the CPU return to the middle of an interrupted system call, the modified
  67. state is almost always incorrect.
  68.  
  69. I hope this helps.
  70.  
  71. Gery Dueck
  72. dueck@brandonu.ca
  73.