So, why the slide said "running in newly created child process" when the return value =0? Does it mean that the child process is not running when the return value>0? It said "running in parent process" when the return value>0.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
About fork() return value: This slide said fork command return an integer. In my understanding, both parent and child processes are running concurrently after this code. So, why the slide said "running in newly created child process" when the return value =0? Does it mean that the child process is not running when the return value>0? It said "running in parent process" when the return value>0.
Process Creation (Cont.)
I fork () System call creates a copy of current process with a new pid
I The return value from fork()- two integer values, one for parent, one for
child
• When > 0:
• Running in (original) parent process
• The return value (positive integer) is pid of newly created child
• When = 0:
%3D
• Running in newly created child process
• When < 0: (When = -1)
» Error! Must handle somehow
» Running in original process
All state of original (parent) process duplicated in the child process
• Memory, file descriptors, and etc.
Because the child is a copy of the parent, each process has its own copy
of any data.
Transcribed Image Text:Process Creation (Cont.) I fork () System call creates a copy of current process with a new pid I The return value from fork()- two integer values, one for parent, one for child • When > 0: • Running in (original) parent process • The return value (positive integer) is pid of newly created child • When = 0: %3D • Running in newly created child process • When < 0: (When = -1) » Error! Must handle somehow » Running in original process All state of original (parent) process duplicated in the child process • Memory, file descriptors, and etc. Because the child is a copy of the parent, each process has its own copy of any data.
Expert Solution
Step 1

Explanation:-

Fork() System call is used to create a new process, known as the child process. The fork is an operation where a process creates a copy of itself. The new copy is called the 'child process' while the original one is said 'parent process'.

After the creation of the new process both the processes(parent process and the child process) runs concurrently. Parent process makes the fork() call. When the new process is created, both the process follows or executes the same instruction which follows the fork() system call.

The use of fork() is to create a new process only. The child process uses the same files, registers, and program counter as the parent process.Fork() System call returns the value without taking parameters.

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education