Other than malloc/free does a program need the OS to provide anything else?

后端 未结 7 1972
逝去的感伤
逝去的感伤 2021-02-02 02:34

I\'m working on designing the kernel (which I\'m going to actually call the \"core\" just to be different, but its basically the same) for an OS I\'m working on. The specifics o

7条回答
  •  梦谈多话
    2021-02-02 03:30

    Generally, the C library handles the implementation of malloc, requesting memory from the OS (either via anonymous mmap or, in older systems, sbrk) as necessary. So your kernel side of things should handle allocating whole pages via something like one of those means.

    Then it's up to malloc to dole out memory in a way that doesn't fragment the free memory too much. I'm not too au fait with the details of this, though; however, the term arena comes to mind. If I can hunt down a reference, I'll update this post.

提交回复
热议问题