Reputation: 799
I want to implement a Queue
struct (using Node
struct, similiral to the C
code here) in files Queue.c
and Queue.h
in order to store processes in proc.c
in XV6
kernel.
I don't know how to to do it, since it requires to use malloc
, but I can't use it inside methods which I call from the kernel.
What can I use instead, in order to implement and use the Queue
?
Upvotes: 1
Views: 3869
Reputation: 5291
You will probably have to implement something similar to the user malloc code (user/malloc.c), for the kernel. For example, look at the file kernel/string.c. It's contents are very similar to user/ulib.c. In this way, the kernel and user space have their own versions of functions like memset
.
The code from user/umalloc.c cannot just be copied and pasted into a kernel version. You'll have to make tweaks for it to work in kernel space. For example changing how morecore
grows the space managed by the allocator...
Upvotes: 1