[ale] compiled system calls versus shell scripts

Doug McNash dmcnash at charter.net
Wed Oct 22 21:33:19 EDT 2003


>void main() {
>  system("modprobe whatever &");
>  system("ifconfig eth0 192.168.0.4 &");
>}
>

Ouch! That would be twice as slow since each system() 
would fork&exec a sh which would then fork&exec the 
command.  Fork&exec is a long and involved sequence of 
events == slow.

What you might want to do is make the same system calls 
that ifconfig, modprobe, and so on do in a C program and 
avoid the fork&exec.  Most utilities boil down to doing 
one or two specific system calls.  Of course, modprobe, 
for instance will open and parse modules.conf for aliases 
and arguments and /lib/modules/2.X.x/modules.dep for 
dependencies as well as sanity checks before doing the 
call. You could do all that manually in the C program for 
everything you need to setup.  It would be totally 
inflexible and very difficult to maintain but would 
greatly speed your boot time. Plus you would have to 
figure out all the system calls and arguments you need, a 
perhaps a serious learning experience.

Have you looked at busybox?  It provides a stripped down 
init scheme as well as a one stop source for most of the 
utilities you would need.  The LinkSys WRT54g uses it (as 
well as running an embedded linux kernel).  This box also 
has a binary rc file like what I have tried to described 
above and boots quite fast.  At least that's what I think 
it is as I have not fully reverse engineered it yet.

Check out 
http://www.seattlewireless.net/index.cgi/LinksysWrt54g
It's a very interesting site. You might find some ideas 
there.  Sorry I can't distill it further at the moment.

This link will tell you how to recover the file system for 
the above.
http://www.cs.helsinki.fi/linux/linux-kernel/2003-23/0035.html
--
Doug McNash <dmcnash at yahoo.com>



More information about the Ale mailing list