作業系統›Ch4 行程與執行緒管理
第 63 題/共 70 題
◀ OS 63/70
63. fork()、Process Creation
#OS-04-063易fork()Process Creation

Consider the C code on the right side. A user executes the executable of the code on a Linux shell. Assume it executed successfully. How many processes have been created by executing the C code, including the original process that executes main()?

int main() {
  pid_t pid;
  int i=0;
  for (i=0;i<4;i++) {
    pid = fork();
    if (pid <0) {
      fprintf(stderr,"fork error\n");
      exit(-1);
    }
  }
  return 0;
}
📄 中央111
跳轉到第題
▤完整推導請見《WH 資工筆記 · 作業系統》Ch4 行程與執行緒管理
本章題號 · 61–70 / 70