Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
17
I've attached the assignment instructions in the zip file, as well as the other necessary files, including some source code. I need everything under "Submissions" in the pdf completed and sent to me.
IMPORTANT: Please explain what commands should be used on the terminal to get the programming running.
Attachments
Unix Pipes/part1.o
Unix Pipes/StarterCode.c
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<string.h>
#include<sys/wait.h>
int main()
{
// We use 4 pipes
// First pipe to send input string from parent
// Second pipe to send concatenated string from child
// Third pipe to send concat string from parent
// Fourth pipe to send reversed string from child
char fixed_str[] = " world";
char input_str[100];
pid_t p;
p = fork();
if (p < 0)
{
fprintf(stderr, "fork Failed" );
return 1;
}
else if (p > 0)
{
// Parent process
p = fork();
if (p < 0)
{
fprintf(stderr, "fork Failed" );
return 1;
}
else if (p > 0)
{
}
else // child process
{
exit(0);
}
}
else // child process
{
exit(0);
}
}
Unix Pipes/Unix Pipes.pdf
Unix Pipes
Operating Systems
Overview
The aim of this lab is to familiarize you with pipes in Linux. Pipes are a common form of inter-process
communication.
Structure
The assignment is broken into three main parts. In each part, you will learn about a different way to
implement pipes. The three parts are as follows:
1. Basic Pipes
2. Named Pipes
3. Pipe System Call
Basic Pipes
Basic pipes can be created in the terminal by placing the “|” operator between commands. Using “|”
causes the output of the left command to be piped in as the input to the right command. For example,
running “cat result.txt | grep -o "COP4600" | wc -l" would return the number of times that the pattern
“COP4600” is found in result.txt. The contents of the file are being piped into the grep command which
then passed any matches into the wc command. The “wc -l” option returns the number of newlines
which, in this case, equals the number of occurrences of the pattern.
For this part, an executable file named “part1.o” is provided via Canvas. When run, the executable will
perform basic operations until it encounters a failure. The amount of successful operations completed
before failing will vary. Here is a sample output of this program:
Your task is to create a C++ program that, when the output of “part1.o” is piped in, determines which
operation number caused the failure. For example, your program would print “Program failed on
operation 12” if it were run with the information from the above screenshot. For this part you will need
to submit a screenshot that shows your code successfully running twice with input provided by “part1.o”
through a basic pipe.
Named Pipes
Named pipes, also known as FIFOs (first-in first-out), are functionally similar to basic pipes except they
are represented as a special file and are, therefore, a non-temporary part of the filesystem. A FIFO can
be created using the “mkfifo [name]” command (similar to mkdir). A FIFO does not store the
communicated data in the file system and only acts as a reference point for processes to establish a
connection. Because of this, when a writer process opens the FIFO, it will block until a reader process
opens the other end. Utilizing named pipes through the command line, therefore, will likely require
multiple terminal windows.
For this part, implement the following:
1. Create a named pipe.
2. Modify your part 1 C++ code to read its input from a file (your named pipe). This program
should be named “lastname_part2.cpp” where “lastname” is your last name.
3. Run “part1.o” and redirect its output into the named pipe.
4. Compile and run your part 2 program (input should not be redirected from the command line).
5. Repeat steps 3 and 4 then take a screenshot that shows the programs running to completion
twice. Be sure to include all terminal windows that were used.
Pipe System Call
Both piping methods used above have required some form of post-compile time actions (i.e. redirecting
output or creating a named pipe). In many cases, this may be a drawback. To set up a pipe entirely
within the process’ code, the pipe system call can be used.
For this part you will use the “fork()” and “pipe()” system calls to implement the following:
1. Create a new C++ program named “lastname_part3.cpp” where “lastname” is your last name.
The program should accept 5 command-line arguments (all integers).
2. The program should create two new child processes and utilize four pipes.
3. The parent process will send the 5 integers to the first child process using a pipe. This child will
sort the integers and send the result to the parent process and the second child process using one
pipe for each. The parent will print the result.
4. After receiving the sorted list from the first child process, the second child process will identify
the median value of the list and send the result to the parent using a pipe. The parent will print
the result.
5. Take a screenshot of the program running with the following integers passed in as command-line
arguments (in the specified order): 42, 15, 8, 16, and 23.
Submissions
You will submit the following at the end of this exercise on Canvas:
● Screenshot of the output from running your part 1 program with a basic pipe twice. ●
Screenshot of the output from running your part 2 program with a named pipe twice.
● C++ source file for your part 2 program named “lastname_part2.cpp” where “lastname” is your
last name.
● Screenshot of the output from running your part 3 program with the required values. ● C++
source file for your part 3 program named “lastname_part3.cpp” where “lastname” is your last
name.
Helpful Links
https://www.linuxjournal.com/article/2156
https://www.tldp.org/LDP/tlk/ipc/ipc.html
http://www.cplusplus.com/doc/tutorial/files/
http://www.gnu.org/software/libc/manual/html_node/Creating-a-Pipe.html
http://man7.org/linux/man-pages/man2/pipe.2.html
Unix Pipes/part1.o
Unix Pipes/StarterCode.c
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<string.h>
#include<sys/wait.h>
int main()
{
// We use 4 pipes
// First pipe to send input string from parent
// Second pipe to send concatenated string from child
// Third pipe to send concat string from parent
// Fourth pipe to send reversed string from child
char fixed_str[] = " world";
char input_str[100];
pid_t p;
p = fork();
if (p < 0)
{
fprintf(stderr, "fork Failed" );
return 1;
}
else if (p > 0)
{
// Parent process
p = fork();
if (p < 0)
{
fprintf(stderr, "fork Failed" );
return 1;
}
else if (p > 0)
{
}
else // child process
{
exit(0);
}
}
else // child process
{
exit(0);
}
}
Unix Pipes/Unix Pipes.pdf
Unix Pipes
Operating Systems
Overview
The aim of this lab is to familiarize you with pipes in Linux. Pipes are a common form of inter-process
communication.
Structure
The assignment is broken into three main parts. In each part, you will learn about a different way to
implement pipes. The three parts are as follows:
1. Basic Pipes
2. Named Pipes
3. Pipe System Call
Basic Pipes
Basic pipes can be created in the terminal by placing the “|” operator between commands. Using “|”
causes the output of the left command to be piped in as the input to the right command. For example,
running “cat result.txt | grep -o "COP4600" | wc -l" would return the number of times that the pattern
“COP4600” is found in result.txt. The contents of the file are being piped into the grep command which
then passed any matches into the wc command. The “wc -l” option returns the number of newlines
which, in this case, equals the number of occurrences of the pattern.
For this part, an executable file named “part1.o” is provided via Canvas. When run, the executable will
perform basic operations until it encounters a failure. The amount of successful operations completed
before failing will vary. Here is a sample output of this program:
Your task is to create a C++ program that, when the output of “part1.o” is piped in, determines which
operation number caused the failure. For example, your program would print “Program failed on
operation 12” if it were run with the information from the above screenshot. For this part you will need
to submit a screenshot that shows your code successfully running twice with input provided by “part1.o”
through a basic pipe.
Named Pipes
Named pipes, also known as FIFOs (first-in first-out), are functionally similar to basic pipes except they
are represented as a special file and are, therefore, a non-temporary part of the filesystem. A FIFO can
be created using the “mkfifo [name]” command (similar to mkdir). A FIFO does not store the
communicated data in the file system and only acts as a reference point for processes to establish a
connection. Because of this, when a writer process opens the FIFO, it will block until a reader process
opens the other end. Utilizing named pipes through the command line, therefore, will likely require
multiple terminal windows.
For this part, implement the following:
1. Create a named pipe.
2. Modify your part 1 C++ code to read its input from a file (your named pipe). This program
should be named “lastname_part2.cpp” where “lastname” is your last name.
3. Run “part1.o” and redirect its output into the named pipe.
4. Compile and run your part 2 program (input should not be redirected from the command line).
5. Repeat steps 3 and 4 then take a screenshot that shows the programs running to completion
twice. Be sure to include all terminal windows that were used.
Pipe System Call
Both piping methods used above have required some form of post-compile time actions (i.e. redirecting
output or creating a named pipe). In many cases, this may be a drawback. To set up a pipe entirely
within the process’ code, the pipe system call can be used.
For this part you will use the “fork()” and “pipe()” system calls to implement the following:
1. Create a new C++ program named “lastname_part3.cpp” where “lastname” is your last name.
The program should accept 5 command-line arguments (all integers).
2. The program should create two new child processes and utilize four pipes.
3. The parent process will send the 5 integers to the first child process using a pipe. This child will
sort the integers and send the result to the parent process and the second child process using one
pipe for each. The parent will print the result.
4. After receiving the sorted list from the first child process, the second child process will identify
the median value of the list and send the result to the parent using a pipe. The parent will print
the result.
5. Take a screenshot of the program running with the following integers passed in as command-line
arguments (in the specified order): 42, 15, 8, 16, and 23.
Submissions
You will submit the following at the end of this exercise on Canvas:
● Screenshot of the output from running your part 1 program with a basic pipe twice. ●
Screenshot of the output from running your part 2 program with a named pipe twice.
● C++ source file for your part 2 program named “lastname_part2.cpp” where “lastname” is your
last name.
● Screenshot of the output from running your part 3 program with the required values. ● C++
source file for your part 3 program named “lastname_part3.cpp” where “lastname” is your last
name.
Helpful Links
https://www.linuxjournal.com/article/2156
https://www.tldp.org/LDP/tlk/ipc/ipc.html
http://www.cplusplus.com/doc/tutorial/files/
http://www.gnu.org/software/libc/manual/html_node/Creating-a-Pipe.html
http://man7.org/linux/man-pages/man2/pipe.2.html
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: Unix Pipes or similar questions only at Tutlance.
Related Questions
- I Need To Run A Mapreduce Word Count Program On Aws.can Someone Meet Me On And Help Me With This On Screen Sharing?
- Sql Homework
- Hackerrank Contacts Problem
- Crc Detection And Checksum Comparison
- C++/Aarch64
- C++ Operator Overloading
- C++ Operator Overloading
- ( I Am Currently In Japan So I Am 14 Hrs Ahead Of The Us Right Now...the Deadline Is Approximately 16Hrs Away)
- Geomatics Database Homework W/ Access
- Principles Python Programming 22 Assignments
- C++ Threading
- Data Structures And Algorithm Assessment
- Floating-Point Arithmetic 32-Bitt Calculator.
- Facial Recognition System
- Computational Learning Theory
- Malware Analysis
- Mips Assembly Language Homework
- In This Assignment You Will Create An Agent To Solve The 8-Puzzle Game.
- Project One: Technology, Hardware, And Software
- Penetration Testing
- Cmpt 200 Coding Homework
- Stacks And Queue Assignment In C++
- Intro To Comp Science Java Program W/ Classes
- Assignment 1
- Assignment 1
- Computer Science Create Task Based On Requirements Of Ap Computer Science Test +Reflection
- Module 1: Technical Assignment - Sales Data Analysis Using Spreadsheets
- Binary Arithmetic
- Coding (Graphs)
- Show All Work Done For Each Problem And Choose The Exact Answer
- Show All Work Done For Each Problem And Code And Use Online [ Https://Www.onlinegdb.com/ ] And Use Language Python 3
- Java Program For Intro To Comp Sci
- Ass. Theory And Practice 8 Questions
- Generating The Sides Of A Right Triangle.
- Programming Assignment
- Short, Easy Assessment On Writing Classes
- Python Object Oriented Programming Weather Assignment (Introductory Level)
- Online Shop Using Spring Mvc Or Ajax Or Java Server Faces
- 36 Questions
- System Scripting Fundamentals Exam (Python)
- C++ Project
- Steal Credentials For Windows Machines In A Lab Video
- Lab/Project - Python
- Forum - Python
- Python Programming - Creating Visualization Using Graph
- Latex Assignment
- Python Program Creating Graph Visualization
- Programming Dice Game On Python Programming
- Please See Attached File For Instructions.
- Design And Implement An Algorithm In Python