www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/20/13:18:31

From: kriiid AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: allocating memory using DPMI
Date: Wed, 20 Oct 1999 16:19:00 GMT
Organization: Deja.com - Before you buy.
Lines: 97
Message-ID: <7ukq18$cde$1@nnrp1.deja.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 991018101754 DOT 3777F-100000 AT is>
NNTP-Posting-Host: 212.160.52.203
X-Article-Creation-Date: Wed Oct 20 16:19:00 1999 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)
X-Http-Proxy: 1.1 x42.deja.com:80 (Squid/1.1.22) for client 212.160.52.203
X-MyDeja-Info: XMYDJUIDkriiid
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
>
>On Sun, 17 Oct 1999 kriiid AT my-deja DOT com wrote:
>
>> Well, the first question is: when I get SIGSEGV there is written
>> information about segments. What does limit section mean?
>
>It's one less than the segment size in bytes.
>
>> I thought
>> this is size of segment. But now I don't think so, cause values like
>> 0x8ffff are not really possible
>
>Why not?  0x8ffff is 589823 bytes: not too much for a typical DJGPP
>program.  Especially since 524288 bytes (512K) out of this amount is
>the run-time stack, which is allocated at startup in its entirety.


Well... I ment it's incredibly small. At least for me. So what if I'd
like to allocate ie. 10 MB? Would djgpp extend this segment to ~11MB?
It look pretty inefficient (if it is done for every malloc).

>> the most essential function - allocating memory (501h). So I
>> made program which just allocates some memory. I run it under
windows.
>> So, linear address is 05DAC000h. And now the funny part. Base address
>> of DS/CS is 83046000h ;-). So now I've got a problem.
>
>Please explain why this is ``a problem''.  I don't see any problem
>here.  You might base your judgement on some incorrect assumptions.

May be.
Well I try to access this memory using DS or CS. So the offset would
have to be negative.
Of course I can create new segment for this memory, but I think it
wouldn't be comfortible to use it...

>> So I run it under DOS.
>> Allocated addres is 200B0000h, while base addres is 10000000h. It
looks
>> OK, but when I try to write there I get a beautiful SIGSEGV.
>
>Post the code that you used to do this.  There's probably some bug in
>how you access that memory.

        mov ax,6
        mov bx,ds
        int 31h

        jc memer

        shl ecx,16
        mov cx,dx
        mov [base],ecx

        mov ax,0501h
        mov bx,0
        mov cx,8000
        int 31h

        jc memer

        shl ebx,16
        add ebx,ecx

        mov [precoo],ebx

And then I just use [precoo]...
So you say it's wrong

 >In general, I suggest to read the DPMI spec carefully.  For example,
>it tells you that allocating memory does not yet allow to access it.
>You also need either to enlarge your DS segment to allow for the
>newly-allocated memory be part of it, and sometimes change the base
>address as well, or create a separate selector for the allocated
>memory.

Thanks... I'll try this.
Changing base is not really a good idea, because what to do with data
allocated within DS using db or something.

>Do you have some particular application for calling DPMI functions
>directly, rather than using malloc?  If so, I suggest to tell what
>application do you have in mind;

I'm actually coding an intro, so it have to be small.

     May the Force be with ya,
     Michal 'CreeD' Szostakiewicz
buttman AT boss DOT staszic DOT waw DOT pl ew. gerwek AT polbox DOT com
ICQ - 2482112
"Only in America we stamp our God
<<In God we Trust>>"


Sent via Deja.com http://www.deja.com/
Before you buy.

- Raw text -


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