From Social Wolf, 2 Months ago, written in C (for LoadRunner).
  1. We have the following program (named prog after compilation):
  2.  
  3. int main(){
  4. if(fork() > 0){
  5. wait(NULL);
  6. }else{
  7. printf("I'm pickle rick!!!");
  8. }
  9. return 0;
  10. }
  11.  
  12. What is the MAXIMUM amount of processes that can run in the system at any time (discarding the shell process) if we run the following bash script: for i in {1...N}; do ./prog; done ?
  13. My answer was 2N because for each iteration we create two processes.
  14. The answer of our teacher:
  15. The father waits for the son, and therefore, each iteration of the bash loop cannot end until both the son and father have finished working. Therefore, a maximum of 2 processes can run on the system, excluding the Shell process.
  16.  
  17. Why is that? we run ./prog every time as a different process, how come we wait until the program ends to continue the for loop?
  18.  
  19.  
captcha