Unlocking task_list read lock before performing a sleepy operation

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

 



Dear All,


I was trying the following and had a doubt.


From my kernel module I want to iterate over task list and do some sleepy operation for all the process for which my task->flag is set .I know by holding read_lock(tasklist_lock)/rcu_read_lock I should not be performing any sleepy operation. So I have coded like below :

 

1.  Take the read lock

2.  Iterate over task (for_each_process)

3.  If my flag is set I unlock the tasklist_lock and get_task_struct

4.  Perform the sleepy operation

5.  Then put_task_struct

6.  Again take read_lock(&tasklist_lock);

7.  Loop continues 

 

The code snippet is as shown below :


read_lock(&tasklist_lock);

 

 for_each_process(c) {

 

  if (c->my_flag) {

 

          read_unlock(&tasklist_lock);

 

           get_task_struct(c);


                    ...


                    perform_sleepy_operation();


                     ...

 

            put_task_struct(c);

 

             read_lock(&tasklist_lock);

                 }

  

         }

 

Please let me know if this approach is correct.


Thanks and Regards,

Pranami


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[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