(Assume child0 is the first/oldest child, child3 is the youngest/last child of parent process…)īy using pointer which is pointing to some filed in the target data struct and list_entry macro, we can have a pointer pointing to the data structure itself now. Here is a more detailed explanation of how list_entry works: List_entry take the pointer and it’s name in the data structure, calculate the offset between the head of the data structure and the field and subtract the pointer by offset. Ptr is the pointer pointing to a field ( in this case, a list_head), type is the type of the aim data (in this case, task_struct), member is what that filed is called in that data_structure. List_entry( ptr,type,membe) is a macro provided by linux kernel. We need to use a macro called list_entry to do that. The interesting thing is that we can’t get the information we want ( for example, task_struct of the child process) directly by using the linked list. list_head contains two pointers, prev and next, which forms a double linked list. In task_struct, there are fields “children” and “sibling” of type list_head. In linux, linked list is implemented using a data structure called “list_head” (defined in linux/list.h ). The overall method is a bit weird as both my teammate and I have never seen that kind of implementation of linked list before. We get a pointer to current process’s task_struct by using an inline function called current (defined in asm/current.h).Ĭhallenges are mainly how the linux kernel manage the relationship between process and its children/ parent/ siblings. In linux kernal, all the information about a process is stored in a data structure called task_struct. We used linux-2.6.26.5 as the basic kernel (Seems it’s called DEBIAN?) So basically we are using something called QEMU to simulate the hardware environment so it can run the OS. The tutorial about adding a system call is here: The basic tutorial about using QEMU is here:
0 Comments
Leave a Reply. |