Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program should produce output like this, when launched from a terminal. [Parent] Created string of 200000000 bytes. [Parent] pid: 11862 [Parent] Sent message to

The program should produce output like this, when launched from a terminal.

[Parent] Created string of 200000000 bytes.

[Parent] pid: 11862

[Parent] Sent message to child, mode 0 (named pipes)

[Child ] pid: 11866

[Child ] Message received, mode 0 (named pipes).

[Parent] Data Verification: PASSED

[Parent] Sent message to child, mode 1 (shared memory)

[Child ] Message received, mode 1 (shared memory).

[Parent] Data Verification: PASSED

Press ENTER to continue...

---------------------------------------------------------------------------------------

#include #include #include

using namespace std;

// Generates a string of ASCII characters for use as data // Takes in an integer that specifies how many bytes/chars the string contains char * GenerateData (int numberOfBytes) { char * result = new char[numberOfBytes];

char value = 65; for (int i = 0; i < numberOfBytes; i++) { result[i] = value++;

if (value > 126) value = 65; }

result[numberOfBytes-1] = '\0';

return result; }

void parent () { // TODO: Setup POSIX message queues for the parent and child processes. (5 pts) // TODO: Transfer the data string to the child process. Send a message to the child process using // the message queue setup earlier. The message should communicate the size of the data being // transferred and the IPC mode the parent is using. This transfer will be over a Named Pipe. // Call the Named Pipe CPSC351-PIPE (10 pts)

// TODO: Transfer the data string to the child process. Send a message to the child process using // the message queue setup earlier. The message should communicate the size of the data being // transferred and the IPC mode the parent is using. This transfer will use shared memory. // Use a bounded buffer to synchronize the transfer between the parent and child processes. (20 pts)

// TODO: Terminate the child process and then proceed to cleanly // end the parent process. (5 pts) // TODO: Wait for a message from the child process. The message will // indicate if the transfer was successful. Display the result // to the terminal for the user to see. (10 pts) }

void child () { // TODO: Setup POSIX message queues for the parent and child processes. (5 pts)

// TODO: Wait to receive a message from the parent process. Ready the // child process to receive data using the method specified in the message. (5 pts)

// TODO: Receive data from the parent using a named pipe. (5 pts)

// TODO: Receive data from the parent using shared memory. (15 pts) // TODO: Verify the received data by comparing it with a generated string of // the same size. Send a message to the parent process that indicates the // result. (5 pts) }

int main(int argc, char **argv) { // TODO: Take in a command line parameter that represents the size, // in bytes, of the string that will be sent to the child process // using IPC. (5 pts)

// TODO: Generate a string of characters of length specified by // the passed in parameter value. See provided GenerateData function. (5 pts) // TODO: Launch the child process. Display the pid of the parent to the // to the terminal. The child process should also display its pid after // launch. (5 pts) return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago

Question

2. Develop a program for effectively managing diversity.

Answered: 1 week ago