Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 2: Introduction to Processes Objective: In this lab, you will gain hands-on experience with fundamental concepts of processes in Linux, including process creation

Lab 2: Introduction to Processes Objective: In this lab, you will gain hands-on experience with fundamental Task: Process Creation and PID Retrieval Instructions: 1. Create a new C program called process_creation.c.

Lab 2: Introduction to Processes Objective: In this lab, you will gain hands-on experience with fundamental concepts of processes in Linux, including process creation using fork() and retrieving process IDs using getpid() and getppid()). Background Information: . The fork() system call returns 0 to the child process to indicate that it has successfully forked from the parent. The parent process receives the PID of the child or -1 if the child did not fork successfully. .getpid() Function: The getpid() function is used to retrieve the Process ID (PID) of the current process. It returns the PID as an integer. .getppid() Function: The getppid(0) function is used to retrieve the PID of the parent process. In a child process, calling getppid(0) will return the PID of the parent process. Task: Process Creation and PID Retrieval Instructions: 1. Create a new C program called process_creation.c. You may want to use this: #include #include #include int main() { *** return 0; 2. Write the C code to create a child process. The parent process must display its PID and its child PID. The child process also must display its PID and its parent PID. Note that the parent process needs to call wait function at the end to avoid creating a zombie process. 3. Compile your program using the following command: gcc process_creation.c -o process_creation 4. Run your program using the following command: /process_creation 5. Observe the output of your program. 6. Take a screenshot of the terminal showing the program's output. 7. Upload the following to Canvas: Your process_creation.c source code file. The screenshot of the program's output. Conclusion: In this lab, you embarked on a practical journey into the world of processes within a Linux environment. You delved into fundamental concepts surrounding processes, honing your skills in process creation and PID retrieval using fork()), getpid(), and getppid(). Lab 2: Introduction to Processes Objective: In this lab, you will gain hands-on experience with fundamental concepts of processes in Linux, including process creation using fork() and retrieving process IDs using getpid() and getppid()). Background Information: . The fork() system call returns 0 to the child process to indicate that it has successfully forked from the parent. The parent process receives the PID of the child or -1 if the child did not fork successfully. .getpid() Function: The getpid() function is used to retrieve the Process ID (PID) of the current process. It returns the PID as an integer. .getppid() Function: The getppid(0) function is used to retrieve the PID of the parent process. In a child process, calling getppid(0) will return the PID of the parent process. Task: Process Creation and PID Retrieval Instructions: 1. Create a new C program called process_creation.c. You may want to use this: #include #include #include int main()) { *** return 0; 2. Write the C code to create a child process. The parent process must display its PID and its child PID. The child process also must display its PID and its parent PID. Note that the parent process needs to call wait function at the end to avoid creating a zombie process. 3. Compile your program using the following command: gcc process_creation.c -o process_creation 4. Run your program using the following command: /process_creation 5. Observe the output of your program. 6. Take a screenshot of the terminal showing the program's output. 7. Upload the following to Canvas: Your process_creation.c source code file. The screenshot of the program's output. Conclusion: In this lab, you embarked on a practical journey into the world of processes within a Linux environment. You delved into fundamental concepts surrounding processes, honing your skills in process creation and PID retrieval using fork(), getpid(), and getppid().

Step by Step Solution

There are 3 Steps involved in it

Step: 1

processcreationc code include include include int main pidt parentpid childpid Fork a child processc... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Programming questions

Question

Distinguish among the various types of trade symbols.

Answered: 1 week ago

Question

Discuss the potential civil liabilities under the 1933 Act.

Answered: 1 week ago