0% found this document useful (0 votes)
23 views3 pages

Oslab Manual-JNTUH

The document discusses writing C programs to illustrate interprocess communication (IPC) mechanisms. It provides an algorithm for the programs and an example program using pipes to communicate between processes.

Uploaded by

Anon One
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Oslab Manual-JNTUH

The document discusses writing C programs to illustrate interprocess communication (IPC) mechanisms. It provides an algorithm for the programs and an example program using pipes to communicate between processes.

Uploaded by

Anon One
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1

5. Write C programs to illustrate the following IPC mechanisms

Aim: Write C programs to illustrate the following IPC mechanisms

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 :
a) PIPE PROCESSING
#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_LE]; 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);
}
strncpy(message,"Understanding ",MSG_LEN); result=write(fd[1],message,strlen(message)); if
(result < 0){
perror("write"); exit(2);
}
strncpy(message,"Concepts of ",MSG_LEN); result=write(fd[1],message,strlen(message)); if (result <
0){
2

perror("write"); exit(2);
}
3

You might also like