In terms of memory allocation efficiency is it right to say that after a fork()
in the code of the child if I execute a program with execve()
this would be more efficient than the same program executed without execve()
because the child won't have allocated the stack and heap of the father but only is own?
Naife example:
without execve
[..some father code...]
int i;
if(!fork()) {
sum() //from an #include "porg.h"
}
with execve
[..some father code...]
if(!fork()) {
execve("sum", NULL, NULL); //sum is a program which executes i=2+3
}
The second in terms of memory allocation is better? Is it better to replace the entire virtual address space of my process or it is better to get running the mentioned code with a call to a function in another program which is included with #include "prog" in terms of number of number of operations done by the so and in terms of the memory carried behind during the execution of the program?