C program that illustrates two processes communicating using shared memory

#include #include #include #include struct country { char name[30]; char capital_city [30]; char currency[30]; int population; }; int main(int argc,char*argv[]) { int shm_id; char*shm_addr; int*countries_num; struct country*countries; struct shmid_ds shm_desc;…

Continue ReadingC program that illustrates two processes communicating using shared memory

C program to create a message queue with read and write permissions to write 3 messages to it with different priority numbers

msgget():The msgget function can be used to create the message queue. msgrcv():The msgrcv function can be used to receive the messages. msgsnd():The msgsnd function can be used to send the…

Continue ReadingC program to create a message queue with read and write permissions to write 3 messages to it with different priority numbers

C programs that illustrate communication between two unrelated processes using named pipe

#include #include #include #include int main() { int pfds[2]; char buf[30]; if(pipe(pfds)==-1) { perror("pipe"); exit(1); } printf("writing to file descriptor #%dn", pfds[1]); write(pfds[1],"test",5); printf("reading from file descriptor #%dn ", pfds[0]);…

Continue ReadingC programs that illustrate communication between two unrelated processes using named pipe

Program that illustrates how to execute two commands concurrently with a command pipe

#include #include #include int main() { int pfds[2]; char buf[30]; if(pipe(pfds)==-1) { perror("pipe failed"); exit(1); } if(!fork()) { close(1); dup(pfds[1]; system (“ls –l”); } else { printf("parent reading from pipe…

Continue ReadingProgram that illustrates how to execute two commands concurrently with a command pipe

C program to create a child process and allow the parent to display “parent” and the child to display “child” on the screen

#include #include /* contains prototype for wait */ int main(void) { int pid; int status; printf("Hello World!n"); pid = fork( ); if(pid == -1) /* check for error in fork…

Continue ReadingC program to create a child process and allow the parent to display “parent” and the child to display “child” on the screen