TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DARIN MCBRIDE
from: GERRY DANEN
date: 1997-08-10 22:27:00
subject: C++ or ASM?

 GD> I've never used volatile on any direct screen I/O.  Perhaps that's
 GD> because under single-tasking DOS that's not a problem.  In what way
 GD> would I see problems under multi-tasking OS like WinNT or OS/2?
 DM> Something tells me you just wanted the answer to the other question,
 DM> but had to keep it on topic.  That's ok - I'm not the moderator, and
 DM> thus the moderator isn't so anal that he'd care.  :-)  [There's an
 DM> implication in there somewhere... ]
I hope Tom isn't reading this... 
 DM> Anyway, you would use volatile under DOS for global variables that are
 DM> modified by interrupts, or anything else modified by interrupts for
 DM> that matter.
Or another process?
 DM> For example, if you had an interrupt that changed a global stack to
 DM> add each new character that came in from a modem, anything dealing with
 DM> the stack would have to be considered volatile (in OS/2 or NT, you
 DM> would use semaphores to guarantee the variable didn't change between
 DM> accesses).  Another one would be, say a pointer to the incoming byte of
 DM> a serial port - this would be volatile as well.
You're over my head here.  If I am using the modem under NT, say in a
bbs program, would I get down to the stack level?
 DM> OS/2 and WinNT have semaphores that render volatile mostly useless.
 DM> Only your own process threads can modify your variables, and all these
 DM> variables can be protected by semaphores.  If they aren't so protected,
 DM> you run into race conditions that can make the system blow up.  ;-)
Wonderful! :(
 DM> Same for DOS, but you don't have as much power over it, so you use the
 DM> volatile.
 DM> (The screen isn't going to change, so having a volatile pointer to it
 DM> is useless... unless you have an interrupt handler also modifying it.)
What about concurrent DOS windows?...
Gerry Danen (gdanen@accessweb.com) C+Net BBS @ 403-477-9545
            http://www.geocities.com/SiliconValley/Way/9823
2 years, 143 days, 1 hour, 43 minutes, and 58 seconds until January 1, 2000.
... Your message was passed on to those you give a sh!t...
--- Maximus 3.01
---------------
* Origin: C+Net BBS. Programming & Networking. (1:342/1017)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.