Hey Guys
I am trying to implement the malloc function for my OS class and I am having a little trouble with it. I would be really grateful if I could get some hints on this problem.
So I am using a doubly-linked list as my data structure and I have to allocate memory for it (duh...). The problem is that I am not allowed to use malloc for this(which makes sense because I am implementing one. I laugh really hard when people use malloc in their own implemented malloc replacement; belive me I have seen them). Anyways so ya I am confused as to how could you do this. I was thinking of mmap() but that can't work as it requires a file descriptor, moreover I can only call it just once so I have no idea how to do this.
Any help will be greatly appreciated
---------- Post updated at 06:52 PM ---------- Previous update was at 06:51 PM ----------
Now i noe i am not supposed to ask hw problems but I am really confused and I just want hints. My professor is out of town and he will be back later. So i am just worried how can I do this.
Please help guys, any hints???????
---------- Post updated at 07:00 PM ---------- Previous update was at 06:52 PM ----------
Oh I forgot to mention. I am getting memory from OS using mmap and this is the code till now
int fd = open("/dev/zero", O_RDWR);
// sizeOfRegion \(in bytes\) needs to be evenly divisible by the page size
void *ptr = mmap\(NULL, sizeOfRegion,
PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0\);
I need to allocate memory for my list in this memory. Thanks