delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/19/19:03:12

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Urgent: memory protection and graphics
Date: Thu, 20 Nov 1997 18:17:15 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 42
Message-ID: <34747EAB.47A5@cs.com>
References: <b127cd$17135 DOT 33c AT news DOT alberni DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp220.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

wolfman AT cedar DOT alberni DOT net wrote:
> 
> I am writing because I am working on a graphics library and I want to shut of memory
> protection so that I can write to the video buffer like: video_buffer[offset]=color; as
> well as for speed and for compatability with Watcom.  The problem is that I was working
> with line drawing and I was switching in and out of memory protection within the line
> drawing function.  I was disatisfied with the speed, so I descided to switch in and out
> of memory protection outside the function.  My line drawing speed went like a basillion
> times faster!  I am very tempted to shut off memory protection when the graphics mode is
> set and to turn it back on when the program exits.  Is there any proplem with this?  The
> faq and documentation is very vague about the subject.  I desperately need the speed
> increase.  What should I do?

Memory protection is there because, without it, you can easily hose your
computer's internals with a rogue pointer, leading to anything from
crashes to hard lockups to damaged devices (such as a SCSI drive mapped
into conventional memory).

The way many people have suggested to solve the problem is to develop
your code with near pointers enabled in as small a portion as possible,
and only enable them globally once you've gone through the major testing
phases and you are sure that your code is relatively bug-free.  You can
also use code optimizations like double-buffering, where you "draw" to a
buffer in protected mode memory, and only disable memory protection when
you want to blit each frame to the screen.  This should significantly
reduce the overhead from disabling/enabling, without as much risk to
your system.  Double-buffering is substantially faster and "cleaner"
than single-buffering in any case.

I'm sure other people can come up with even more possibilities.  :)

hth

-- 
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? C++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---)
O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++
e(*)>++++ h!() !r !y+()
------END GEEK CODE BLOCK------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019