> The tasklist_lock is a rw spinlock. It is again a > macro defined in <linux/spinlock.h> I donot think it is a macro as I could see it in fork.c rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED; This is a different thing from the error which I encountered: But getting following error: unresolved symbol __read_lock_failed I can see that tasklist_lock is exported. Pls see below output ksyms -a | grep tasklist c0370a80 tasklist_lock_R999c80a2 c011f8e0 check_tasklist_locked_R15bb5893 The cause of problem is something else. On further study, I found that read_lock invokes __read_lock_failed if it fails in acquiring lock and the __read_lock_failed is invoked which again tries to achieve lock. As __read_lock_failed is a function in assembly and not exported, therefore it gives unresolved error. For temporary fix, I defined this function in my module which is as below: void __read_lock_failed(void) { printk("<1> LOCKING FAILED"); } This change helped me to get rid of unresolved error. But when I load this module, I could see that __read_lock_failed has invoked. //Code Snippet read_lock(&tasklist_lock); printk("<1> Iterating "); for_each_process(p) { printk ("<1> Iterating Task List " ); printk ("<1> Process PID=%i, State=%i\n",p->pid,p->state); } Output of code : LOCKING FAILED<1> Iterating <1> Iterating Task List <1> Process PID=1, State=1 Iterating Task List <1> Process PID=2, State=1 Iterating Task List <1> Process PID=3, State=1 I am able to print the task list details successfully. But could nopt able to understand why I failed in obtaining lock. Regards Dinesh --- Manish Regmi <regmi.manish@xxxxxxxxx> wrote: > On 8/13/06, Dinesh Ahuja <mdlinux7@xxxxxxxxxxx> > wrote: > > Hi Manish, > > > > It is just a macro that expands to a for loop. It > is > > deffined in > > sched.h > > > > #define for_each_process(p) \ > > for (p = &init_task ; (p = next_task(p)) != > > &init_task ; ) > > > > Right this is a macro. On further investigation, I > > found that init_task access init_task_union.task > > {defined in include/asm-i386/processor.h} and > > next_task is again a macro defined as > > #define next_task(p) > list_entry((p)->tasks.next, > > struct task_struct, tasks) > > > > list_entry is again a macro defined in > > {include/linux/list.h} as > > #define list_entry(ptr, type, member) \ > > ((type *)((char *)(ptr)-(unsigned > > long)(&((type *)0)->member))) > > > > In this case, macro uses a init_task_union which > is > > exported by kernel and that should be sufficient > for > > module to iterate over list. But if macro is using > an > > kernel symbol i.e function or a global variable, > then > > these symbols should be exported otherwise use of > > macro will give unresolved symbols. Please verfiy > my > > understanding. > > correct. > > > I am trying to use read lock before iterating a > task > > list. > > > > read_lock(&tasklist_lock); > > for_each_process(p) { > > printk ("<1> Iterating > Task > > List" ); > > } > > read_unlock(&tasklist_lock); > > > > But getting following error: > > unresolved symbol __read_lock_failed > > > The tasklist_lock is a rw spinlock. It is again a > macro defined in > <linux/spinlock.h> > > regards > Manish Regmi > __________________________________________________________ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/