Re: kobject_uevent() and sysfs attribute sync

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :)

> 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.

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?

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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux