Lab 2: Introduction to Processes Objective: In this lab, you will gain hands-on experience with fundamental...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <stdio.h> #include <unistd.h> #include <sys/wait.h> 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 <stdio.h> #include <unistd.h> #include <sys/wait.h> 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 <stdio.h> #include <unistd.h> #include <sys/wait.h> 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 <stdio.h> #include <unistd.h> #include <sys/wait.h> 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().
Expert Answer:
Answer rating: 100% (QA)
processcreationc code include include include int main pidt parentpid childpid Fork a child processc... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
Studying about Reserve Bank of Fiji, discuss how do the Reserve Bank of Fiji's actions change the exchange rate? Discuss how traders move funds between countries and into Fiji. Finally discussthe...
-
Before you begin this assignment, be sure you have read the UMUC Family Clinic Case Study below and your Week 1 and Week2 syllabus readings, which discuss EHR functionality and Process...
-
Start by reading both case studies and make notes of the business type, the situation the Entrepreneur/owner finds himself or herself in, and then thoroughly understand not only the depth, but the...
-
Q1. During November, these transactions took place in Singer Inc., a company that uses job order costing: a) Materials purchased on account $35,600. b) Materials issued to fill requisitions on job...
-
Using the information from BE10-14, assume that the company has a December 31 year end and records adjusting entries annually. Record the journal entries relating to the bonds on January 1, July 1,...
-
In your audit of Garza Company, you find that a physical inventory on December 31, 2022, showed merchandise with a cost of $441,000 was on hand at that date. You also discover the following items...
-
Identify at least five sources for locating the whereabouts of a witness.
-
Kate Petusky prepared Addison Controls' balance sheet and income statement for 2013. Before she could complete the statement of cash flows, she had to leave town to attend to a family emergency....
-
Do you recommend a muff with an NRR of 1 9 dB for a workplace that has a running grinding machine that produces 8 9 dB , an oven with 8 7 dB , an agitator with 7 8 dB , and a drill with 8 1 dB ? All...
-
Give a Christian worldview perspective on social media and law enforcement ?
-
2. Design a toll booth Application of Padma bridge. At booth, it will collect the amount of toll from all the vehicles passing through based on the vehicle types (i.e. motorcycle, Buss, Truck, Car,...
-
Using the sum & difference identities, condense each of the following and express as a trig function of a single angle. 1. sin 97 cos 43 + cos 97 sin 43 tan 140 - tan 60* 3. 1+tan 140 tan 60 2. cos...
-
Below are the chunks of code which needs refactoring, make them better in terms of design without changing their behavior. Also state what part you have changed and how it has led to better design....
-
Dr. D is the director of surgery at Union Medical Center. He has long been recognized for his disruptive behavior and outbursts of anger in the OR. Carol, the VP of nursing, makes an appointment to...
-
6. The average hourly earnings, in US dollars, of US production workers for 2005 - 2013 are shown in the table below, where t = 1 corresponds to the year 2005. Year 1 2 3 4 5 6 7 8 9 Average Hourly...
-
Discuss the advantages and disadvantages of Total station surveying?
-
Which of the following raises the credibility of areport? Which of the following raises the credibility of a report? Multiple Choice avoiding predictions avoiding the use of cause-effect statements...
-
Distinguish among the various types of trade symbols.
-
Two-year-old David Allen was bitten by Joseph Whiteheads dog while he was playing on the porch at the Allen residence. Allen suffered facial cuts, a severed muscle in his left eye, a hole in his left...
-
Discuss the potential civil liabilities under the 1933 Act.
-
The National Center for Health Statistics sampled 5844 American women over the age of 20 and found that their median weight was 157.2 pounds. A histogram of the data set was skewed to the right....
-
In a recent year, approximately 1.7 million people took the mathematics section of the SAT. Of these, 42% scored less than 490, 45% scored less than 500, 49% scored less than 510, 52% scored less...
-
The National Health and Nutrition Examination Survey measured the heights, in inches, of a large number of American adult men. Of these heights, 33% were less than 68, 42% were less than 69, 59% were...
Study smarter with the SolutionInn App