Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C or C++ concurrent Shearsort program using basic UNIX system calls for process creation and interprocess communication. You will use system calls such

Write a C or C++ concurrent Shearsort program using basic UNIX system calls for process creation and interprocess communication. You will use system calls such as fork(2), pipe(2), read(2), and write(2) to implement the Shearsort algorithm on multiple UNIX processes (note that the “(2)” in “fork(2)” refers to the section number of the man pages where it can be found). Furthermore, you are to use UNIX message queues to handle the output of the program as explained below. 

You need to create one process for each column and one for each row. Hence, there are 2n processes for n × n elements.
1. Initialize the message queue.
2. Read 16 integers from stdin into a 2-dimensional array. This can be done by the main (parent) program.
3. Print the 16 integers in the original order to stdout.
4. Create pipes by means of the pipe system call for communication between processes. Launch all processes by means of the fork() system call. To handle 16 integers, you will launch 8 processes. Initialize each process of the odd phase by having the main program send each row process its associated four numbers.
5. Perform the required number of odd and even phases, using Bubble Sort in each phase.
6. After the sort has finished, send the array of sorted integers to the message queue. Make sure you do not leave any unterminated forked processes in the system.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Creating a concurrent Shearsort program in CC using UNIX system calls involves managing multiple processes and coordinating communication between them ... 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

Management Accounting Information for Decision-Making and Strategy Execution

Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young

6th Edition

137024975, 978-0137024971

More Books

Students also viewed these Operating System questions