How to represent process-owned objects?
Posted: Sun Sep 27, 2009 12:39 am
As I've been thinking about this for a few days, I may as well post even though once more I really should be sleeping rather than lurking on forums
What are the best ways to represent things/objects that a process or thread might own, such as message queues?
To be specific, message queues in my kernel are in kernel space and used by applications by passing handles into syscalls. The two ways I've thought of attaching said queue handles to the process info structures is:
a) hash tables. Hash the handle (ie the address in kernel space) to a byte, and use that to index list of lists.
b) A linked list of arrays. For example, ten handle elements, eleventh pointer to the next array.
c) Just a continually realloc'd array of handles.
I think I'm leaning towards (a), but I'm also wondering whether this should all be in the process structure, or should each thread have its own "stuff" (I don't think so).
At the very least, any access to the list of objects (however its represented) would need some sort of mutual exclusion, right? One thread could get switched to and create a new message queue while another thread is in the middle of the kernel send_msg syscall and is checking whether the process has access to that queue.
Is there always a lock on any kind of list of things in process structures (such as file handles) ?
Thanks,
- Mike
(PS: I just coded my scheduler and timer IRQ today. Hopefully in the coming weeks I'll have pics of alternating letters in Bochs to show off )
What are the best ways to represent things/objects that a process or thread might own, such as message queues?
To be specific, message queues in my kernel are in kernel space and used by applications by passing handles into syscalls. The two ways I've thought of attaching said queue handles to the process info structures is:
a) hash tables. Hash the handle (ie the address in kernel space) to a byte, and use that to index list of lists.
b) A linked list of arrays. For example, ten handle elements, eleventh pointer to the next array.
c) Just a continually realloc'd array of handles.
I think I'm leaning towards (a), but I'm also wondering whether this should all be in the process structure, or should each thread have its own "stuff" (I don't think so).
At the very least, any access to the list of objects (however its represented) would need some sort of mutual exclusion, right? One thread could get switched to and create a new message queue while another thread is in the middle of the kernel send_msg syscall and is checking whether the process has access to that queue.
Is there always a lock on any kind of list of things in process structures (such as file handles) ?
Thanks,
- Mike
(PS: I just coded my scheduler and timer IRQ today. Hopefully in the coming weeks I'll have pics of alternating letters in Bochs to show off )