I am practicing making device driver programming.
my goal was to get current task's pid, and parent task's pid.
furthermore, I get grand(parent's parent) task's pid.
this is source code.
struct task_struct * current_task = current;
struct task_struct * parent_task = current_task->parent;
printk("current pid : %d, current_task->pid);
printk("parent task pid : %d\n", parent_task->pid);
printk("grand pid : %d\n", parent_task->parent->pid);
this is result.. (I ran this 3 times.)
current pid : 2850 parent task pid : 2846 grand parent task : 1692
current pid : 2872 parent task pid : 2864 grand parent task : 1692
current pid : 2891 parent task pid : 2887 grand parent task : 1692
grand parent task's pid is always 1692.
current's one and parent's one are increasing. I am just wondering why... It will be helpful if someone answer me.. Thanks for reading.