[haiku-gsoc] Re: Implementation Queries

  • From: Hamish Morrison <hamishm53@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Wed, 28 Jun 2017 09:38:10 +0100

On Wed, Jun 28, 2017 at 6:35 AM, Adrien Destugues
<pulkomandy@xxxxxxxxxxxxx> wrote:

It depends which flags are used. You didn't tell us which flags kmalloc
is using in your use cases.

If you don't know which flags are used, I would start with something like 
this:

void* kmalloc(size_t size, uint32_t flags)
{
        if (flags & CONTIGUOUS_MEMORY)
                PANIC("kmalloc doesn't know how to do contiguous memory 
yet!");

        if (flags & ...)
                ...

        // ok, nothing special required. few!
        return malloc(size);
}


The problem is that kmalloc on Linux always returns contiguous memory
(because Linux maps some range of physical memory 1:1 into kernel
virtual address space). So for a correct implementation we need to
always return contiguous memory (although this will be quite expensive
on Haiku).

Other related posts: