www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/25/19:33:51

Message-ID: <33D936DF.4DF8@polbox.com>
Date: Sat, 26 Jul 1997 01:29:35 +0200
From: Tomasz Chojnacki <tcho AT polbox DOT com>
Reply-To: tcho AT polbox DOT com
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Mem mapped device questions

Hi!

I am working with the PC frame-grabber board under DJGPP v1
(gcc v2.6.3).
The board has memory of 1MB and is mapped into PC's address
space at addresses 0xA00000-0xB00000. My computer has 8MB of
memory. I access frame-grabber's memory with the expression:
*(0xE0000000+0xA00000+i).
It works fine but I was wondering why the access to memory mapped
at 0xE0000000 was so slow.
To check that I have performed simple test (PROGRAM_1):

#include <stdio.h>
#include <time.h>
void main()
{
int i, j;
  clock();
  for (j=0; j<1000; j++)
    for (i=0; i<10000; i++)
      *((unsigned char *)(0xE0000000+0xA00000)+i) = 255;
  printf("clock=%ld=%fsec.\n",(long
int)clock(),(float)clock()/CLOCKS_PER_SEC);
}

I have got the clock's result:
clock=19610367=19.610367 sec.
Next I have performed test with the malloced memory (PROGRAM_2):

#include <stdio.h>
#include <time.h>
void main()
{
int i, j;
unsigned char *ptr=(unsigned char *)malloc(10000);
  clock();
  for (j=0; j<1000; j++)
    for (i=0; i<10000; i++)
      *(ptr+i)=255;
  printf("clock=%ld=%f sec.\n", (long
int)clock(),(float)clock()/CLOCKS_PER_SEC);
}

and I have got:
clock=1977516=1.977516 sec.
That is ten times faster than PROGRAM_1.
Next I have tried to access the 7th MB of physical memory (PROGRAM_3):

#include <stdio.h>
#include <time.h>
void main()
{
int i, j;
  clock();
  for (j=0; j<1000; j++)
    for (i=0; i<10000; i++)
      *((unsigned char *)(0xE0000000+0x700000)+i) = 255;
  printf("clock=%ld=%f sec.\n", (long
int)clock(),(float)clock()/CLOCKS_PER_SEC);
}

and I have got:
clock=1867654=1.867654 sec.
- no difference from malloc version (PROGRAM_2) and even faster !!!

Finally I have examined the access to the memory which don't have
representation in the physical memory - for example 9th MB,12th MB etc.
The line 9th of the above program was respectively:
*((unsigned char *)(0xE0000000+0x900000)+i) = 255;
*((unsigned char *)(0xE0000000+0xC00000)+i) = 255; etc.
Each time the result was the same:
clock=16753955=16.753955 sec.

I have following questions:

Why the access to the memory which don't have representation in the
physical memory is so slow and why don't I get 'Segmentation Violation'
when accessing that memory ?

If I changed the frame-grabber base address to the address which
would overlap the physical memory (for example 0x700000) - should
the access to the grabber's memory be faster ?

Should the ``FAT DS'' hack described in the Chapter 18.10 of the FAQ
list (faq102.zip) work with go32 extender and GRX v1.03 library
(which do not work in DPMI) ?

P.S.
I am sorry for my bad English.

- Raw text -


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