Docsity

operating system for computer science, Exercises of Operating Systems

Partial preview of the text

Download operating system for computer science and more Exercises Operating Systems in PDF only on Docsity!

8.PIPE PROCESSING

AIM :

To write a program for create a pope processing ALGORITHM:

  1. Start the program.

  2. Declare the variables.

  3. Read the choice.

  4. Create a piping processing using IPC.

  5. Assign the variable lengths

  6. “ strcpy” the message lengths.

  7. To join the operation using IPC.

  8. Stop the program .

PROGRAM:

#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #define MSG_LEN 64 int main(){ int result; int fd[2]; char message[MSG_LEN]; char recvd_msg[MSG_LEN]; result = pipe (fd); //Creating a pipe//fd[0] is for reading and fd[1] is for writing if (result < 0) { perror("pipe "); exit(1); } strncpy(message,"Linux World!! ",MSG_LEN); result=write(fd[1],message,strlen(message)); if (result < 0) { perror("write"); exit(2);

if (result < 0) { perror("read"); exit(3); } printf("%s\n",recvd_msg); return 0;}

OUTPUT: