I am taking an Operating Systems course and as a project, we are printing the content of the PCB of a process from task_struct of that process and its mm_struct & vm_area_struct pointers. During my stack growth experiments, I used a recursive summation method with parameter n, which returns the sum of first n integers. However I realized that in some cases, same parameters do not result in same growths. What might be the reason for this?
Here's how we find the stack boundaries, in case it is necessary:
- Using for_each_process, we find the task_struct of the process with pid = x
- From task struct, we get the process' mm_struct & vm_area_struct pointers
- Using a linear search, we detect the stack as follows:
vma->vm_start < mm->start_stack && vma->vm_end >= mm->start_stack; where
vmais a virtual_area_struct
Note that this procedure is done with a kernel module.