Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Inter Process communication (IPC) technique supports a thread in one process to share some information with threads in other processes. This can be implemented through
Inter Process communication (IPC) technique supports a thread in one process to share some information with threads in other processes. This can be implemented through shared memory or message passing. A pipe can be used in designing an IPC. Simply, a pipe is a FIFO First in First Out queue or a buffer with two ends: a read end and a write end. A thread can write or read depending on the file reference it has. The system calls, read) is used to read data and write0 is used to write data Programming Task [60 points]: Given the following implementation of Pipe in C Language. (a) run the program and change as necessary to get expected output, (b) briefly explain, whether the implementation is a shared memory or message passing, (c) What part of code you need to modify for other approach of IPC? include include string.h> void main() // www.c-madeeasy.blogspot.com int pid[2],pidl [2],pid2[2],pid3 [2],pid4 [2]; int a[20],nue#0 ; char str [20] pipe (pid: pipe (pidi); pipe (pid2): pipe (pid3) pipe (pid4); if ( fork ( ) =#0 ) sleep (5): close (pid[1]): read (pidr01,str,sizeof (str) : for 4-0, 1-0; str [i != ' \0' ;i++) close (pid3 [0]) write (pid3 [1],&sizeof (1)): sleep (6) printf ( "Enter %d array element: ",1); scanf ("dsali]) close (pidi [0]) write (pid1[1], asizes(a)); close (pid4 [0]) write (pid4[1],ssizeof (1)): else if (fork 00) sleep (2) close (pid1 [1]) close (pid4 [1]): read (pid4[0],ijesizeof (1)) read (pidl [0] ,aaizesf(a)); for (i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started