Site icon Tutor Bin

C Programming Pipe Ping-Pong Worksheet

C Programming Pipe Ping-Pong Worksheet

Description

Write a C program with 4 functions where:

A. Function main:

– Creates two pipes and makes them global.

– Creates two processes. Each process should call a function defined in (B) and (C) below.

– Sends the SIGUSR1 signal to the (C) process before ending.

B. One function should have an integer variable that starts at 0. It should print “ping – <value>” then increment the value. It should write that value to a pipe and read the value back from the other pipe until the value is greater than or equal to 100. It should call exit() when complete.

C. The other function should set up a signal handler for SIGUSR1 to call a function (defined in (D) below) when it receives that signal. It should then loop forever: read from a pipe, print “pong – <value>”, increment the value and write the value to the other pipe. These pipes must be opposite from the function in (B) – the pipe you write to in (B) must be the pipe that you read from in (C) and vice versa.

D. Create a function for the signal handler that should print “pong quitting” and exit().

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Exit mobile version