RTNL sync or async when creating GPRS Context for STE modem.

Rémi Denis-Courmont remi at remlab.net
Sun May 30 12:46:22 PDT 2010


Le dimanche 30 mai 2010 17:45:04 Sjur BRENDELAND, vous avez écrit :
> I have started out by doing the RTNL handling async,
> i.e. registering the RTNL socket with g_io_add_watch etc.
> But I'm not really happy with the code as it feels
> unnecessary complex, introduces new states in gprs-context.c. etc.

Using an event loop makes sense if, and only if, the process blocks as far as 
poll() is concerned. If your ioctl() calls or Netlink requests do not enter 
the kernel scheduler at any point, then the glib main loop will just slows 
things down - more code, more context switches.

As an counter example, some people believe so blindly in event loops that they 
use them to read *regular* files, and then recommend it to their friends. 
Nevermind that POSIX states that regular files are always marked ready for 
POLLIN and POLLOUT events, i.e. poll()'ing a regular file will always return 
immediately. Thus the event loop is defeated, and just constitutes useless 
code complexity and wasted CPU time. (Of course, if the same code path can 
cope with non-regular files, then using poll() might make sense, don't make me 
say what I did not.)

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis


More information about the ofono mailing list