home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.msdos.programmer:9024 comp.os.msdos.misc:5032
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
- Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
- Subject: Re: Why ms-dos is non reentrant
- Message-ID: <1992Sep2.174517.2209@brandonu.ca>
- From: dueck@brandonu.ca
- Date: 2 Sep 92 17:45:17 CST
- References: <92245.122042A10742@TRMETU.BITNET>
- Organization: Brandon University, Brandon, Manitoba, Canada
- Lines: 62
-
- In article <92245.122042A10742@TRMETU.BITNET>, Pinar Aydemir <A10742@TRMETU.BITNET> writes:
- > I almost hear everyday that msdos is non-reentrant.
- > It is non re-entrant so dont call a dos funcion from a Interrupt Service
- > Routine.
- > Since It is non reentrant, bla bla bla.
- >
- > I looked at some books about OS, and the definition of reentrancy is
- > given as being unmodified (pure) code.So, what makes msdos non reentrant ?
- > Any information is appreciated.
- > -Yasemin
-
- That definition is not quite correct. Pure code just means that you don't
- modify code on the fly.
-
- Reentrance requires the notion of a process: code + data. The code
- remains constant, but the data is different for each occurence of a process.
-
- For example:
- x dw 0
-
- incrax:
- mov x, ax
- add x, 1
- mov ax, x
- ret
-
- is not re-entrant, but
-
- incrax:
- push bp
- mov bp,sp
- sub sp, 2
- mov [bp-2], ax
- add [bp-2], 1
- mov ax, [bp-2]
- mov sp, bp
- ret
-
- is re-entrant. The difference? We have to consider that an interrupt handler
- can be invoked at any time (asynchronous), that it may call the incrax routine, and that
- at the time of the interrupt, the CPU was executiong somewhere in incrax
- (what I call a synchronous execution).
-
- In the first example, an interrupt handler invoked asynchronously that
- calls incrax will modify location x, thereby causing an incorrect
- result from the synchronous call to incrax,
-
- An interrupt handler that calls incrax in the second example will not
- clobber location x, since the data areas used by the code is specific
- to an instance of a thread of control. Thus the asynchronous execution
- cannot interfere with the synchronous execution.
-
- In the case of DOS, the state of a system call is stored in fixed locations.
- A system call made from within an interrupt handler modifies the state
- represented by those locations. So when the interrupt completes, and
- the CPU return to the middle of an interrupted system call, the modified
- state is almost always incorrect.
-
- I hope this helps.
-
- Gery Dueck
- dueck@brandonu.ca
-