C
C
ClaraOswald2015-12-22 17:40:04
*nix-like systems
ClaraOswald, 2015-12-22 17:40:04

How to calculate how long it will take to create a child process?

How to calculate how long it will take to create a child process on a UNIX system?
for example, I have all the necessary data:
text size - 100 KB, data size -
20 KB, stack size - 10 KB, task structure size - 1 KB, user structure size - 5 KB. The processing of an emulated interrupt by the kernel takes 1 ms, and the computer can copy a 32-bit word every 50 ns. Text segments are shared, while data and stack segments are not.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Tsilyurik, 2015-12-23
@ClaraOswald

How to calculate how long it will take to create a child process on a UNIX system?

Nonsensical question :-(.
Correct answer: not at all ;-) ... in the sense of vanishingly little to worry about.
In POSIX, when they say "create a child process" they mean, first of all, fork() (although on other systems or under other circumstances they might mean exec*(), spawn*(), and so on... popen() ;-) ).
On modern POSIX systems, doing a fork() doesn't depend on all your kilobytes... or megabytes...
Because when you do a fork(), no such address space is created by the COW (Copy On Write) mechanism. And all the execution time is spent only on executing a system call in the kernel to create a new task entry and put it in a circular process queue.
PS Also, it will be a big surprise for you, I think (but relevant) that the execution time of fork() will be about the same as the time of creating a new thread pthread_create() inside the same process.
PS And if you desperately need to know the fork() time (in the nanosecond range), then use the RDTSC processor cycle counter and the corresponding rdtsc assembler command for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question