공룡 운영체제 3장 연습문제
- 최초 등록일
- 2019.06.01
- 최종 저작일
- 2019.04
- 8페이지/ 한컴오피스
- 가격 1,000원
목차
없음
본문내용
3.1 그림 3.30에 표시된 프로그램을 사용하여 LINE A에서 출력이 어떻게 되는지 설명하십시오.
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
int value = 5;
int main()
{
pid_t pid;
pid = fork();
if (pid == 0) { /* child process */
value += 15;
return 0;
} else if (pid > 0) { /* parent process */
wait(NULL);
printf("PARENT: value = %d",value); /* LINE A */
return 0;
}
}
fork() is a system call used to create processes which takes no arguments and returns a process ID.
When using fork() the new process which is created will become the child process of the caller and both processes will continue execution with the child process and the parent running concurrently.
So there will be two instances of the program running.
The child process will inherit the code, global variables, heaps and stacks, registers, and open files of its parent.
However since the child is a duplicate both the parent and the child will have their own variables in this case the value variable. his means the child process
참고 자료
없음