October 2017
Intermediate to advanced
586 pages
14h 8m
English
Here we will see how not to make CPU wasting polling to sense sysfs attributes data availability. The idea is to use poll or select system calls to wait for the attribute's content to change. The patch to make sysfs attributes pollable was created by Neil Brown and Greg Kroah-Hartman. The kobject manager (the driver which has access to the kobject) must support notification to allow poll or select to return (be released) when the content changes. The magic function that does the trick comes from the kernel side, and is sysfs_notify():
void sysfs_notify(struct kobject *kobj, const char *dir,
const char *attr)
If the dir parameter is non-null, it is used to find a subdirectory, which contains the ...