Page 1 of 1

malloc() in pmode

Posted: Fri Jan 31, 2003 8:48 am
by Adrian
How is this supposed to work? How to allow the program to access the data?

I cannot give away generel linear selectors to PL#3, perhaps I should create a new one for each block

Adrian.

Re:malloc() in pmode

Posted: Fri Jan 31, 2003 10:20 am
by Pype.Clicker
giving each block a separate segment will not work with traditionnal C programming
- because people assume malloc to return a void* and they also assume sizeof(void*) == sizeof(int).
- because you only have 8192 selectors and that you're likely to have more blocks than this ...

I would rather promote the use of segments for some "special things" like shared memory areas, mapped files, etc.

Of course in a perfect world, the compiler would do that for you, but the world isn't perfect :(

Re:malloc() in pmode

Posted: Fri Jan 31, 2003 10:52 am
by Adrian
How does it work then?

Adrian

Re:malloc() in pmode

Posted: Fri Jan 31, 2003 11:40 am
by Pype.Clicker
you usually have one big segment for the data & heap and chunks you got with malloc have no "buffer-overflow" protections (i.e. *(malloc(10)+10)='0' will not necessarily raise an exception, except if the allocated block is next to the latest allocated page.

That's a pity, but from that point of view, Intel Architecture didn't manage what it promised.

Now, maybe with some FARPTR tricks, you could protect some very important buffers, but that's all.

If you need more info on malloc algorithm, i suggest you read the tutorials about memory management (from Tim Robinson's page or Bona Fide Development, i think?

Re:malloc() in pmode

Posted: Sat Feb 01, 2003 4:07 pm
by pskyboy
I didn't find the algorithm for my malloc function to hard to implement and its not that compilcated either. It still doesn't fulyl work at the moment as i have to set up the page fault interupt but i think the malloc function will work alright when it actually has memory behind it.

Peter