Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ in a UNIX Environment Part1 Create a one-directional ring of pipe for N proc

ID: 665572 • Letter: C

Question

C++ in a UNIX Environment

Part1 Create a one-directional ring of pipe for N processes (N 1)

Part2 Create a one-directional ring of pipe for N threads

Part3 Create a one-directional ring of socket for N hosts (or all in one).

                        You may run N processes in one host.

                        Each process has two designated ports - one for sending and the other for receiving.

                        Each program for each process will be run with an argument telling which process (Nth process)

                        You may assume that each process has a table of process with 2 ports as following:

Process i

IP address

Port# to send

Port# to receive

0

127.0.0.1

9000

9001

1

127.0.0.1

9100

9101

2

127.0.0.1

9200

9201

and so on

When N processes (or threads) in a ring are up and ready, Process 0 sends a message to be received by Process 1, and so on, to back to Process 0 and done. Whenever a process sends or receives a message, it prints its process # (N), "the message", and "sent" or "received".

Process i

IP address

Port# to send

Port# to receive

0

127.0.0.1

9000

9001

1

127.0.0.1

9100

9101

2

127.0.0.1

9200

9201

and so on

Explanation / Answer

process i. IP adress.

Port# to send and port# to receive.0.127.0.0.1.9000.9001

Port# to send and port# to receive.1.127.0.0.1.9100.9101

Port# to send and port# to rceive.2.127.0.0.1.9200.9201

process0 sends a message to be received by process 1

process 1 sends a message to be received by process 2 and so on to process 0.

we can send message to a process send/2 and receive process receive/1

send self(),{:hello,"world"}

{:hello,"world"}

receive do

{:hello,msg}-------->msg

{:world,msg} ------>"wont match"

end

"world"

receive do

-----> {:hello,msg}

------> after

......> 1_000 ------>" nothing after 1s"

end

"nothing after 1s"

The port number and network address 127.0.0.1 is as follows:

void setup() {

size(400)(400);

oscP5=new oscP5(this,5001);

myRemoteLocation=new NetAdress("127.0.0.1",5001);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote