About process and threads

The following picture illustrates how the kernel manage a process which has four threads.

When kernel creates a process, a page will be allocated and be used for kproc_t struct, and then kernel creates a main thread with two continuous pages allocated for it. the end of the second page will be used as the kernel mode stack.
All processes and threads are managed by avl tree. A sys_avl_node for keeping all current processes in order,and for each process, it’s own avl node keeping all threads in order.
For a specified process, its cr3(page directory) will be shared for all threads that belongs to him.

Leave a Reply

Your email address will not be published.