[RFC]Something wrong with my module

harryxiyou harryxiyou at gmail.com
Thu Apr 12 09:40:52 EDT 2012


On Thu, Apr 12, 2012 at 7:18 PM, Kristof Provost <kristof at sigsegv.be> wrote:

Hi Kristof

> On 2012-04-12 18:16:56 (+0800), harryxiyou <harryxiyou at gmail.com> 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



More information about the Kernelnewbies mailing list