Note that there are some explanatory texts on larger screens.

plurals
  1. POIn general, on ucLinux, is ioctl faster than writing to /sys filesystem?
    text
    copied!<p>I have an embedded system I'm working with, and it currently uses the sysfs to control certain features.</p> <p>However, there is function that we would like to speed up, if possible.</p> <p>I discovered that this subsystem also supports and ioctl interface, but before rewriting the code, I decided to search to see which is a faster interface (on ucLinux) in general: sysfs or ioctl. </p> <p>Does anybody understand both implementations well enough to give me a rough idea of the difference in overhead for each? I'm looking for generic info, such as "ioctl is faster because you've removed the file layer from the function calls". Or "they are roughly the same because sysfs has a very simple interface".</p> <p><strong>Update 10/24/2013:</strong></p> <p>The specific case I'm currently doing is as follows:</p> <pre><code>int fd = open("/sys/power/state",O_WRONLY); write( fd, "standby", 7 ); close( fd ); </code></pre> <p>In kernel/power/main.c, the code that handles this write looks like:</p> <pre><code>static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND suspend_state_t state = PM_SUSPEND_STANDBY; const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 7 &amp;&amp; !strncmp(buf, "standby", len)) { error = enter_standby(); goto Exit; ((( snip ))) </code></pre> <p>Can this be sped up by moving to a custom ioctl() where the code to handle the ioctl call looks something like:</p> <pre><code>case SNAPSHOT_STANDBY: if (!data-&gt;frozen) { error = -EPERM; break; } error = enter_standby(); break; </code></pre> <p>(so the ioctl() calls the same low-level function that the sysfs function did).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload