How many processes and threads will be created?

后端 未结 3 1159
难免孤独
难免孤独 2020-12-19 06:11

I have this code and trying to understand how many process and threads will be created from this:

pid t pid; 
pid = fork(); 
if (pid == 0) { /* child process         


        
3条回答
  •  执笔经年
    2020-12-19 06:36

    shouldn't it be 2 threads and 6 processes?

    M
    |  ↘
    M     A
    |     |↘
    M     A*   B*
    |     |    |
    | ↘   | ↘  |↘
    M   C A  D B  E
    

    as I use * to represent thread.

提交回复
热议问题