[ale] compiled system calls versus shell scripts
Christopher Bergeron
cbergeron at dashwerks.com
Thu Oct 23 06:29:49 EDT 2003
Aahhh! That explains why when I "time" each I get almost double results
from the compiled binary. I created a shell script and a binary that do
the exact same thing and I got results that were opposite (as you
described) from what I expected. For those that don't know, you can
"time" a command by simply running: ' time whatever.sh ' or ' time
binaryfilename '. When the program is completed, you'll be presented
with a timing calculation of the execution time. As a result (of my
result), I decided to post this thread to the list. Thanks for sheding
some light on it, Doug!!!
Does anyone know how to do the Make / Makefile thing at bootup? How
does one build the makefile, and where do you put it?
So many questions, such little time...
Thanks for all the help -
-cb
Doug McNash wrote:
>> 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>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
>
More information about the Ale
mailing list