Walking all task_struct.

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

 



Hello.

I'm adding a pointer to "struct task_struct".

struct task_struct {
  ...
  void *my_pointer; /* updated on do_execve() */
};

I want to know reference count of
some_address pointed by my_pointer
to implement garbage collector.
The address pointed by my_pointer
is shared by more than 0 "task_struct"s.

I'm not using reference counter method
because I don't want to modify
process creation/duplication/termination functions.


Is the code

struct task_struct *p;
int count = 0;
read_lock(&tasklist_lock);
for_each_process(p) {
  if (p->my_pointer == some_address) count++;
}
read_unlock(&tasklist_lock);

can access all "task_struct"s at that moment?
In other words, is there a moment that
a valid task_struct with my_pointer == some_address
exists but not linked in the tasklist?

Regards.

--
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