Re: Walking all task_struct.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

Rajat Jain wrote:
> > In other words, is there a moment that
> > a valid task_struct with my_pointer == some_address
> > exists but not linked in the tasklist?
> No.
> 
> Thanks,

Thank you, Rajat.
Yes, do_fork() copies task_struct but the copy is not linked in.
But that is acceptable, because (at least)
the original task_struct exists and is linked in,
the for_each_process loop returns count > 0.
So, I can use

struct task_struct *p;
int flag = 0;
read_lock(&tasklist_lock);
for_each_process(p) {
  if (p->my_pointer == some_address) { flag = 1; break; }
}
if (!flag) { /* mark some_address not referenced by any process */ }
read_unlock(&tasklist_lock);

because all I need to know is
"Whether some_address is referenced at that moment?"
to implement garbage collector.

Am I right?

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux