On Wed, Dec 06, 2006 at 11:14:50AM -0300, Mauricio Lin wrote: > --- Greg KH <greg@xxxxxxxxx> escreveu: > > On Tue, Dec 05, 2006 at 08:57:48PM +0000, Mauricio Lin wrote: > > > Hi all, > > > > > > I implemented a module that sends signals to user space using > > > kobject_uevent() when some conditions happen. That step is working. > > > > > > When the signal is sent, a sysfs attribute is also changed (switch > > from > > > 0 to 1 or vice-versa). This means that the corresponding file under > > > /sys/ has its contents modified as well (using "_name"_show(struct > > > subsystem *subsys, char *page) function) . > > > > > > The user space when receives the signal (sent by kobject_uevent()) > > it > > > tries to read the file under /sys (that was changed to 1 when the > > > signal was sent), but the value is always 0. IMHO there is a sync > > > problem, because when user space gets the signal and it reads the > > file > > > under /sys, the value set to 1 (notify moment) could be changed > > back to > > > 0 (read moment) later. > > > > Then userspace isn't getting there fast enough it seems :) > > Yes, that's right. Then your design is wrong, you need to rethink what you are wanting to achieve here. > > > So is there any way to send a signal and guarantee that the > > attribute > > > will be read by user space before being changed by subsequent > > actions? > > > Is sysfs_notify() a possible solution for that? > > > > How about just poll() on the sysfs file? That way your program gets > > woken up, and you read the proper data. > > Humm, is it efficient? It must be something that does not consume much > memory. Memory where? In the kernel or in userspace? > > But what is the real thing you are trying to do here? It seems you > > are > > trying to use sysfs in an odd way, perhaps you might want to do > > something else? > > Humm, you gave me an idea. I have just to send the signal when the > attribute is changed to 1 and not 0, so there is no need to include an > additional read from user space to check if the value is 1 again. > > Let me check the code again :) You didn't answer my question about what you are trying to do here... thanks, greg k-h -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/