Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

** I'VE CREATED THE PROGRAM THAT GENERATES THE COLLATZ SEQUENCE, I NEED HELP WITH CREATING A PROGRAM THAT USES A SHARED MEMORY OBJECT ** In

  1. ** I'VE CREATED THE PROGRAM THAT GENERATES THE COLLATZ SEQUENCE, I NEED HELP WITH CREATING A PROGRAM THAT USES A SHARED MEMORY OBJECT **

  2. In Exercise 3.21, the child process must output the sequence of numbers generated from the algorithm specified by the Collatz conjecture because the parent and child have their own copies of the data. Another approach to designing this program is to establish a shared-memory object between the parent and child processes. This technique allows the child to write the contents of the sequence to the shared-memory object. The parent can then output the sequence when the child completes. Because the memory is shared, any changes the child makes will be reflected in the parent process as well.

    This program will be structured using POSIX shared memory as described in Section 3.5.1. The parent process will progress through the following steps:

    1. Establish the shared-memory object (shm open(), ftruncate(), and mmap()).

    2. Create the child process and wait for it to terminate.

    3. Output the contents of shared memory.

    4. Remove the shared-memory object.

      One area of concern with cooperating processes involves synchronization issues. In this exercise, the parent and child processes must be coordinated so that the parent does not output the sequence until the child finishes execution. These two processes will be synchronized using the wait() system call: the parent process will invoke wait(), which will suspend it until the child process exits.

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions