
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
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

Transcribed Image Text:Part 1: Working With Process IDs
Process ID: 3329
Part 2: Working With Multiple Processes
I just became a parent!
I am a child process!
I am bored of my parent, switching programs now
My child process just terminated!
Part 3: Working With External Commands
total 52
-rwxr-xr-x 1 ubuntu ubuntu 14570 Jan 20 20:21 Assignment_3_2
-rw-r--r-- 1 ubuntu ubuntu 1124 Jan 20 20:18 Assignment_3_2.cpp
-rw-r--r-- 1 ubuntu ubuntu 4984 Jan 20 20:21 Assignment_3_2.o
-rw-r--r-- 1 ubuntu ubuntu 378 Jan 20 20:18 Makefile
-rw-r--r-- 1 ubuntu ubuntu 1466 Jan 20 20:20 Processes.cpp
-rw-r--r-- 1 ubuntu ubuntu 495 Jan 20 20:18 Processes.h
-rw-r--r-- 1 ubuntu ubuntu 5088 Jan 20 20:21 Processes.o
-rw-r--r-- 1 ubuntu ubuntu
905 Jan 20 20:18 Processes_SK.cpp
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 nowThis is a popular solution!
Step by stepSolved in 3 steps with 8 images

Knowledge Booster
Similar questions
- in pythonarrow_forwardThis is a main module. w7_main Module (supplied) Do not modify this module! Look at the code and make sure you understand it. // Workshop 7 // Version: 1.0 // Author: Asam Gulaid // Description: // This file tests your workshop 7 ///////////////////////////////////////////// #include<iostream> #include "Minister.h" #include "Minister.h" // intentional #include "MemberParliament.h" #include "MemberParliament.h" // intentional using namespace std; using namespace sdds; void printHeader(const char* title) { char oldFill = cout.fill('-'); cout.width(62); cout << "" << endl; cout << "|> " << title << endl; cout.fill('-'); cout.width(62); cout << "" << endl; cout.fill(oldFill); } void newElections(Minister& aMinister, const char* district, const char* newPM, double year) { aMinister.NewDistrict(district); aMinister.changePM(newPM); aMinister.assumeOffice(year); cout << "Status of New Election " << aMinister << endl…arrow_forwardWhich is the Parent class for all exceptions? (1) std::bad_exception(2) std::logic_error(3) std::exception(4) std::runtime_errorarrow_forward
- What kind of exceptions are captured during the compilation process of the program?arrow_forwardFocus on Basic file operations, exception handlingCreate and save a file of the number below as module6data.txt: 26O76-9185-4485-95-3483-64-76-4189083-99-698-790-32-49-898579-285619-93-21-238251-80l62-78-87128-730-45-7328-5O-7063-36-720-76-24-590-548335-388-1429-351727-61-4249833879-803384196-944671876-63-3693-82-68-2069-57-84-29-177736-89-946210-69-43Write a program in python that will a. Open the file module6data.txtb. Create a second file named processed.txtc. Read the numbers from the first file one at a time. For each number write into thesecond file, if possible, itsi. square ii. square root.iii. reciprocal (1/number) each on a separate line.• Use a math module function for the square root.• Use exception handling to trap possible errors. Error messages should be reported to the screen.d. Report the number of items in the original file and the number that were successfully stored in the second file.e. Report the number (count) of each type of error: ValueError, ZeroDivisionError,…arrow_forwardChapter 6 complete the following Programming Exercises. #3 Line Numbers #6 Average of Numbers #7 Random Number File Writer #9 Exception Handling (this one is just a revised version of #6 above) Note: You will need to create a few text files to test your code. Using notepad or any other text editor (not MS word!) to create some text files that contain sample data. Save your files with the extension ".txt". Be sure to submit your sample text files with your lab.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

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