At Linux Kernel 2.6.15 kernel/timer.c , memory barrier is used. 
 
I can't understand why memory barrier must be used. 
 
 
/* comment */
asmlinkage long sys_getppid(void)
{
 int pid;
 struct task_struct *me = current;
 struct task_struct *parent;
 parent = me->group_leader->real_parent;
 for (;;) {
 pid = parent->tgid;
#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
{
 struct task_struct *old = parent;
 
 /*
 * Make sure we read the pid before re-reading the
 * parent pointer :
 */
 
 smp_rmb(); <----- Why ?
 parent = me->group_leader->real_parent;
 if (old != parent)
 continue;
}
#endif
 break;
 }
 return pid ;
}
I read code comment also, But I can't find any reason.
 
How pid variable is read after parent pointer re-reading ?
 
Please, let me know ...
 
Thank you for your help..
 
 
 
 
 
 
ohojang님의 블로그
안녕하세요.

Reply via email to