🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1258

Re: Why ms-dos is non reentrant

#1258
From: dueck
Date: Wed, 02 Sep 1992 23:45
62 lines
2558 bytes
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
Technical Details
Message-ID: <1992Sep2.174517.2209@brandonu.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
References: <92245.122042A10742@TRMETU.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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