Date: Mon, 18 Oct 1999 10:18:30 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: kriiid AT my-deja DOT com cc: djgpp AT delorie DOT com Subject: Re: allocating memory using DPMI In-Reply-To: <7uc7hu$m6f$1@nnrp1.deja.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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. > 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. The base address of the DS segment is an arbitrary number that is up to the DPMI host to decide, and for all practical purposes a DJGPP program shouldn't care about the base address at all. > 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. 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. 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; it is possible that you can accomplish that without all these complications.