Practice mode Operating Systems

Counting the original process, how many processes exist after the C code for (int i = 0; i < 3; i++) fork(); has run?

Correct answer D. 8

Explanation

Each fork() doubles the number of processes, because every existing process executes the next call. After one iteration there are 2, after two there are 4, and after three there are 2^3 = 8, including the original parent. The answer 3 counts only the calls, and 4 forgets that children created in earlier iterations also keep looping.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.