C++ Part 1: Working With Process IDs Modify the getProcessID() function in the file named Processes.cpp The function must find and store the process's own process id The function must return the process id to the calling program. Note that the function currently returns a default value of -1. Hint: search for “process id” in the “System Calls” section of the Linux manual. Take a screenshot of a sample output and upload the picture as part of your assignment submission. Part 2: Working With Multiple Processes Modify the createNewProcess() function in the file named Processes.cpp as follows: The child process must print the message I am a child process! The child process must then return a string with the message I am bored of my parent, switching programs now The parent process must print the message I just became a parent! The parent process must then wait until the child process terminates, at which point it must return a string with the message My child process just terminated! and then terminate itself. Hint: search for “wait for process” in the “System Calls” section of the Linux manual. Part 3: Working With External Commands Modify the replaceProcess() function in the file named Processes.cpp as follows: The parent process will use the fork() function to create a child process. This step has been done for you. The child process must then change its memory image to a different program by using the execvp system call (http://linux.die.net/man/3/execvp). The parameter args that has been passed to the replaceProcess() function is the array of parameters to be passed to execvp, telling it which program to execute and what parameters to pass to that program. For example, the test code provided to you executes the “ls” (directory list) program with the parameter “-l” by setting the args array as follows: char * args[3] = {(char * )"ls", (char * )"-l", NULL}; Finally, in the parent process, you must make sure to invoke the necessary system call to wait for the child process to terminate. Once the child terminates, exit the program. OUTPUT IN IMAGES
C++ Part 1: Working With Process IDs Modify the getProcessID() function in the file named Processes.cpp The function must find and store the process's own process id The function must return the process id to the calling program. Note that the function currently returns a default value of -1. Hint: search for “process id” in the “System Calls” section of the Linux manual. Take a screenshot of a sample output and upload the picture as part of your assignment submission. Part 2: Working With Multiple Processes Modify the createNewProcess() function in the file named Processes.cpp as follows: The child process must print the message I am a child process! The child process must then return a string with the message I am bored of my parent, switching programs now The parent process must print the message I just became a parent! The parent process must then wait until the child process terminates, at which point it must return a string with the message My child process just terminated! and then terminate itself. Hint: search for “wait for process” in the “System Calls” section of the Linux manual. Part 3: Working With External Commands Modify the replaceProcess() function in the file named Processes.cpp as follows: The parent process will use the fork() function to create a child process. This step has been done for you. The child process must then change its memory image to a different program by using the execvp system call (http://linux.die.net/man/3/execvp). The parameter args that has been passed to the replaceProcess() function is the array of parameters to be passed to execvp, telling it which program to execute and what parameters to pass to that program. For example, the test code provided to you executes the “ls” (directory list) program with the parameter “-l” by setting the args array as follows: char * args[3] = {(char * )"ls", (char * )"-l", NULL}; Finally, in the parent process, you must make sure to invoke the necessary system call to wait for the child process to terminate. Once the child terminates, exit the program. OUTPUT IN IMAGES
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
C++
Part 1: Working With Process IDs
- Modify the getProcessID() function in the file named Processes.cpp
- The function must find and store the process's own process id
- The function must return the process id to the calling program. Note that the function currently returns a default value of -1.
Hint: search for “process id” in the “System Calls” section of the Linux manual.
Take a screenshot of a sample output and upload the picture as part of your assignment submission.
Part 2: Working With Multiple Processes
- Modify the createNewProcess() function in the file named Processes.cpp as follows:
- The child process must print the message I am a child process!
- The child process must then return a string with the message I am bored of my parent, switching programs now
- The parent process must print the message I just became a parent!
- The parent process must then wait until the child process terminates, at which point it must return a string with the message My child process just terminated! and then terminate itself. Hint: search for “wait for process” in the “System Calls” section of the Linux manual.
Part 3: Working With External Commands
- Modify the replaceProcess() function in the file named Processes.cpp as follows:
- The parent process will use the fork() function to create a child process. This step has been done for you.
- The child process must then change its memory image to a different program by using the execvp system call (http://linux.die.net/man/3/execvp). The parameter args that has been passed to the replaceProcess() function is the array of parameters to be passed to execvp, telling it which program to execute and what parameters to pass to that program.
For example, the test code provided to you executes the “ls” (directory list) program with the parameter “-l” by setting the args array as follows:
char * args[3] = {(char * )"ls", (char * )"-l", NULL};
- Finally, in the parent process, you must make sure to invoke the necessary system call to wait for the child process to terminate. Once the child terminates, exit the program.
OUTPUT IN IMAGES
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 8 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY