On Fri, 27 Dec 2002, devnetfs wrote: > --- zw <zhaoway@public1.ptt.js.cn> wrote: > > I think you don't have to do anything special before you call > > copy_to_user() in your kernel_thread() if you've got the right > > pointer. > > But I thought while doing copy_to_user() the task should have > a valid task->mm. no? I think this is the point. copy_to_user takes a virtual address supplied by the user code. If you are executing in the context of the appropriate process, then the memory system is set up to translate this appropriately. If you aren't executing in the context of the appropriate process, then I don't think copy_to_user can help you. In principle, you could find the appropriate physical address (from the user virtual address) and write directly to this. You still need to be careful in that the physical page could have move (be swapped to disk and back to a different memory location). I don't think you want to do things the way you are thinking of doing them. In any case, copying something to user space is of little use until the user process runs again. One solution would be to have a thread in the user process sleeping, and let that thread copy the data into user space, and then return to the user to allow the user to process it. Another solution might be to signal the user process and have the user process make a system call from within the signal handler (I think this is "legal"). Best wishes, Mike -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/