Board index » delphi » Protected Mode problem in Borland Pascal

Protected Mode problem in Borland Pascal

I am having some problems allocating a lot of storage in
protected mode and was wondering if someone out there could help
narrow down my search: I suspect my computer rather than the code.
The program simply allocates 60KB blocks in extended storage,
copies from an existing block to the new block, then accesses each
byte of that storage.

The following test program runs to completion without errors,
and returns to the IDE and seems to be fine.

As soon as I try to do something else (move the cursor around
the source) the system locks up with a parity error and has
to be reset (very occasionally I can exit BP without a reset).

Occasionally the program stops part way through with a parity error,
again causing a reset.

Is there some brave soul out there that could try this program
and let me know if it fails on their machine too? You will need
at least 10 megs of ram. If indeed the code is at fault, you might
get a parity error as well.

Thanks,

program wptest;

uses crt, winapi;

const
   pagesize        = 60 * 1024;

type
   page            = array[1 .. pagesize] of byte;
   pageptr         = ^ page;
   pagevec         = array[1 .. 16000] of pageptr;

   { 60K per page, 16,000 pages, should be able to allocate
     960,000K bytes }

var
   pages           : ^ pagevec;
   pagect          : word;

function
   pagealloc       : boolean;
  {---------
   allocate one page, the next page, pagect }
begin
   inc(pagect);
   pages^[pagect] := globalallocptr(gmem_fixed, pagesize);
   if pages^[pagect] = nil then begin
      pagealloc := false;
      exit;
   end;
end;

procedure
   ramtest;
  {-------
   find out why cannot allocate all of ram }
var
   i               : word;
begin
   new(pages);

   if not pagealloc then begin
      writeln('pagealloc failed on first try');
      exit;
   end;

   for i := 1 to pagesize do
      pages^[1]^[i] := byte(i);

   while pagect < 128 do begin
      pagealloc;
      pages^[pagect] := pages^[1];
      for i := 1 to pagesize do
         if pages^[pagect]^[i] <> pages^[1]^[i] then begin
            writeln('mismatch on compare ', pagect:8, i:8);
            exit;
         end;
      writeln(pagect:5, memavail:10);
   end;
end;

begin
   ramtest;
end.
--
Brent Beach, Victoria, BC

 

Re:Protected Mode problem in Borland Pascal


Quote
Brent Beach wrote:

> I am having some problems allocating a lot of storage in
> protected mode and was wondering if someone out there could help
> narrow down my search: I suspect my computer rather than the code.
> The program simply allocates 60KB blocks in extended storage,
> copies from an existing block to the new block, then accesses each
> byte of that storage.

> The following test program runs to completion without errors,
> and returns to the IDE and seems to be fine.

> As soon as I try to do something else (move the cursor around
> the source) the system locks up with a parity error and has
> to be reset (very occasionally I can exit BP without a reset).

> Occasionally the program stops part way through with a parity error,
> again causing a reset.

AFAI can tell, no need to run your program: parity
errors are hardware (memory) errors and generate a
hardware interrupt (NMI?, vague recollection).
Your error message should not be a BP error message
with the corresponding messagebox, rather a DOS-style
error message.

What surprises me is that the self-test doesn't catch
it (or you might try re-enabling it). Both the POST
and himem test memory before proceeding.

If you can, you might try disabling part of your RAM
to locaise the error, then replace the faulty chip/SIMM/
DIMM or whatever form you use. (if you are still using
SIMMs [I am], you should need to replace only 1 SIMM of
the faulty bank, only you have to try which one).

Good luck,

Remco
--
R.J. Vi?tor                    |  AFE Chemistry
remco @ chem.gla.ac.uk         |  Joseph Black Building
                               |  University of Glasgow
The views expressed in this    |  Glasgow G12 8QQ
message represent only the     |  UK
personal views of the author   |

Other Threads