Le Wed, 25 Jul 2007 09:23:33 -0400
Mike Frysinger <[EMAIL PROTECTED]> a écrit:


> > Theorically 3 scripts = 3 shells = 3 system calls.
> 
> you cant equate 3 shells to 3 system calls ... simply executing `bash` will 
> execute many more system calls than just one.

Oh, yes the term "system call" is maybe improper, here. I thought to the
"system" function in Perl... I should have said "you will ask to the
system to launch the command three times instead of one", so there are
three initializations instead of one, whatever a single initialization
does.

> > So, IMHO the most 
> > efficient must be to launch one script. After, it depends on the code
> > you execute : if there are many system calls and few needs in memory,
> > you probably won't see the difference.
> 
> since each script is really just /bin/bash (or whatever), the appropriate 
> sections are shared in memory automatically.  an independent script is pretty 
> much the same as backgrounding something as the shell will fork a new process 
> for each one.  so you still have 3 processes.

Is there no difference at all between a job and a parallel shell ? it's
a true question... Seen from "outside" I had the feeling a job
was more "integrated" to its parent shell in order to allow jobs
control. Is it just a story of "naming space" (sorry, I haven't
the appropriate terms) without any physical reality, which for example
would say to a shell: "you can know when this process will end because
it's your son but for this one you'll have to deal with 'ps' because
it's not" ?

However with 3 scripts executing each one command, you should have 6
processes unless you specify 'exec' in them (the processes of the shells
+ ones of the commands), while with 3 commands backgrounded in one
script, you should have 4 processes. But what you mean is that
*physically* one or thousand 'bash' processes is the same thing,
have I well understood ? :)

> about the only thing you could say is how long running is the script.  if it 
> is long running, then the difference will probably be negligible.  if it's 
> something that gets executed over and over, spawning subshells may be 
> slightly cheaper than forking whole new shells for each script.  but really, 
> this is all just conjecture ... the only real test is one you run yourself 
> and gather quantitative data about resource utilization.

In fact the difference I was conceiving was a difference between a
script which would have combine many commands, and a script which would
have use primarily the internal functions of the shell (few forks). With
the second ones, the cost of the extra initializations should be
*relatively* sensible but not in the first ones where it should be
drowned in all system calls, shouldn't it ?

++
Seb.
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to