[Gllug] perl eval()
Nix
nix at esperi.demon.co.uk
Thu Jun 20 22:40:16 UTC 2002
On Thu, 20 Jun 2002, Bruce Richardson moaned:
> On Thu, Jun 20, 2002 at 05:55:48PM +0100, will wrote:
>> Yeah, the code is pretty simple, but when perl 'Evaluates the expression or
>> code in its argument at runtime as a separate Perl program' to interpret
>> the eval (quote from perl in a nutshell, oreilly), does this mean that perl
>> (about 5 Mb?)interpreter is loaded into memory again doubling the number of
>> interpreters running
>
> No, Linux is cleverer than that. Only one copy of the binary is read
> into memory (and only as much is read in as is actually needed, which is
> called Demand Paging) and this is shared between all the processes using
> it. There will be two sets of resources - though even there the kernel
But the fork() is still comparatively expensive: while it is much
cheaper than a fork() on Solaris and immensely cheaper than an NT
process creation, it still has to mess with page tables, which isn't
cheap.
In fact, it doesn't do any kind of fork(), as this nanoscopic script
shows:
,----
| #!/usr/bin/perl -w
|
| eval
| {
| system ("ps");
| }
`----
perl seems to treat eval as a sort of deformed cross between a function
call and a catch block (which the Perl interpreter has internally).
The code's in pp_ctl.c:S_doeval(), but be warned, the insides of Perl
are even uglier than the outsides.
--
`What happened?'
`Nick shipped buggy code!'
`Oh, no dinner for him...'
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list