Re: [RFC]Something wrong with my module

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

 



On Thu, Apr 12, 2012 at 7:18 PM, Kristof Provost <kristof@xxxxxxxxxx> wrote:

Hi Kristof

> On 2012-04-12 18:16:56 (+0800), harryxiyou <harryxiyou@xxxxxxxxx> wrote:
>> Hi greg,
>>
>>     I write a module for inserting a PCB or delete a PCB to kernel's
>> PCB tree, but when i run it something wrong happens to me like following.
>> My environment is "Linux 10 2.6.35-22-generic #33-Ubuntu SMP Sun Sep
>> 19 20:34:50 UTC 2010 i686 GNU/Linux"
>>
>>
>>       printk("Search for insert task-------->\n");
>>       task = &init_task;
>>       list_for_each(pos, &task->tasks) {
>>               p = list_entry(pos, struct task_struct, tasks);
>>               count++;
>>               if (0 == p->pid) {
>>                       rm_task(p);
>>               }
>>               printk("pid: %d, state: %ld, comm: %s\n", p->pid, p->state, p->comm);
>>       }
>>
> You're iterating over the tasks list without locking it.
>
> What do you think happens if someone else comes along and modifies it
> while you're reading it?

Hmmm, Yes, i should lock it.
>
> Try to take the tasklist_lock.

I will try, thanks.


-- 
Thanks
Harry Wei

_______________________________________________
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