lab4 Process
  • Introduction
  • Knowing about process
    • Checking System Process
    • Process Identification
  • Let's Fork! Process Creation
    • Background of Process Creation
    • fork system call
    • Distinguish Parent and Child Process
    • Exercises
  • Process Execution
    • First exec example
    • Environment Variables
    • exec Family
    • exec Family: execlp
    • exec Family: execle
    • exec Family: execv
    • exec Family: execvp
    • exec Family: execve
    • exec error handling
  • Wait!
    • Problem 1: Without Wait?
    • Sleep
    • Problem 2: Zombies!
    • Wait System Call
    • waitpid
Powered by GitBook
On this page

Was this helpful?

  1. Let's Fork! Process Creation

Exercises

Take a note of the program below. It has several fork() and printf(). How many A, B and C will be printed?

/* LetsFork/fork_ex.c */
#include <stdio.h>
#include <unistd.h>
int main(int argc,char *argv[]){
    printf("A\n");
    fork();
    printf("B\n");
    fork();
    printf("C\n");
    return 0;
}

How many A, B and C will be printed?

(a). A: 1 time, B: 2 times, C: 2 times

(b). A: 1 time, B: 2 times, C: 4 times

(c). A: 1 time, B: 1 time, C: 2 times

(d). A: 1 time, B: 2 times, C: 3 times

PreviousDistinguish Parent and Child ProcessNextProcess Execution

Last updated 4 months ago

Was this helpful?