Thread (11 messages) 11 messages, 4 authors, 2012-04-13

[RFC]Something wrong with my module

From: Kristof Provost <hidden>
Date: 2012-04-12 11:18:39

On 2012-04-12 18:16:56 (+0800), harryxiyou [off-list ref] 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?

Try to take the tasklist_lock.

Regards,
Kristof
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help