Program for Inter Process Communication using Message Queues || msgget || msgsnd || msgrcv || IPC

  Рет қаралды 41,807

DexTutor

DexTutor

Күн бұрын

In this lecture on Program for Inter Process Communication using Message Queues, you will learn how processes can communicate using message queues in Linux using C programming. Message queues are almost similar to named pipes with the exception that they do not require the opening and closing of pipes. But, they face one similar problem like named pipes; blocking on full pipes. Message queues send blocks of data from one process to another.
There are 4 important functions that we will use in the programs to achieve IPC using message queues
int msgget(key_t key, int msgflg);
int msgsnd(int msqid, const void *msg_ptr, size_t msg_sz, int msgflg);
int msgrcv(int msqid, void *msg_ptr, size_t msg_sz, long int msgtype, int msgflg);
int msgctl(int msqid, int command, struct msqid_ds *buf);
Subscribe - / dextutor
This lecture is part of the Operating System Lab playlist: • Operating System Lab
For Program code and more details visit: dextutor.com/p...
Reference Videos for Inter Process Communication:
1. IPC using pipe(): • Program for Inter-Proc...
2. IPC using named pipes: • Program for Inter-Proc...
3. IPC using Shared memory: • Program for Inter-Proc...
4. IPC using message queues: • Program for Inter Proc...
5. IPC using popen: • Program for Inter-Proc...
Tools Required:
1. Linux environment
2. Basic knowledge of C Language
3. gcc compiler installed
Reference Links:
Operating System Theory PPTs Link: dextutor.com/c...
Operating System Programs: dextutor.com/c...
Other Playlists:
OS: • Operating System
Linux Essential: • Linux Tutorial For Beg...
RHCSA: • RHCSA Exam Questions |...
Was this tutorial about Program for IPC using message queues helpful? If so, please share. Let me know your thoughts in the comments.
#linux #oslab #os #dextutor #ipc

Пікірлер: 22
@nithishjh5251
@nithishjh5251 3 жыл бұрын
Thanks a lot sir for helping. Your Teaching is superb.
@zhoualias5481
@zhoualias5481 Жыл бұрын
This video is very nice, it help me to understand message queue!
@rrohith5202
@rrohith5202 3 жыл бұрын
Sir, I don't know why but I'm unable to get the output for the second (recieve) program . I'm doing it on ubuntu in my windows os
@dextutor
@dextutor 3 жыл бұрын
This will not work in WSL in windows ( the one which you are using) for this program you need a pure Linux environment
@shivanisrivastava6360
@shivanisrivastava6360 2 жыл бұрын
@@dextutor Same problem, I am not getting output of second program.. I did on linux virtual box.. Receiver program is not responding, it is not receiving the message.. i checked all syntax.. from video and blog both.. please give solution...on how to run on virtual box linux/Ubuntu?
@dextutor
@dextutor 2 жыл бұрын
Please share the command that you are using to run the programs.. Also drop a mail at dextutor@gmail.com with snapshots ..
@athulu8655
@athulu8655 2 жыл бұрын
@@shivanisrivastava6360 changing key_t to the same in both files helped
@srikanthreddy9330
@srikanthreddy9330 Жыл бұрын
I am unable to send void* type data inside a structure and getting output as segmentation fault
@dextutor
@dextutor Жыл бұрын
Check your code
@nikhilkumar_2788
@nikhilkumar_2788 9 ай бұрын
Hey great content, But please update your site I do not feel safe in going to your site through my office laptop
@girikgarg1268
@girikgarg1268 3 жыл бұрын
HI! Can you please tell me why do I need to create a structure to send the message when I am using message queues? I mean, there is no such requirement while sending messages using shared memory, then why do I require it here? Would be grateful if you reply :)
@dextutor
@dextutor 3 жыл бұрын
Message queues send blocks of data from one process to another. Each block is considered to have a "type". Thus for each data block there will be two things: data and type. Ao, structure is the best way to define two values with an object
@samadeekshareddy7958
@samadeekshareddy7958 3 жыл бұрын
sir, fgets means is it storing in a file?
@dextutor
@dextutor 3 жыл бұрын
Not in file but in the variable named "buffer". Whatever data you input using keyboard will be saved in buffer and then we copy it from buffer using strcpy into some_text
@deekshareddysama9890
@deekshareddysama9890 3 жыл бұрын
@@dextutor thank you sir
@madhurikabudaraju4378
@madhurikabudaraju4378 3 жыл бұрын
hello sir, i tried executing this program in ubuntu app on my windows OS, it did not create any message queue, what could be the reason?
@dextutor
@dextutor 3 жыл бұрын
Because WSL does not support SysV message queues
@woodseller1939
@woodseller1939 Жыл бұрын
Just my 1 rupee opinion/comment & please take it FWIW. This is a good introductory program for new learners. In an real world programming scenario, like in a good software development company - in the mq_send.c file being shown in this youtube video, we should set the integer variable "running" to 0 if the msgget() system call fails. This will ensure that the program prints the error message related to Message Queue creation failure and does not even enter the "while(running)" loop. Otherwise the program will enter the while loop and all the messages obtained from the user input will never ever get sent to the receiver program. I do see that there is an exit(0) line when Message Queue creation is a failure in the mq_send.c source code file in your indicated website. Here too , the usage of "exit(0)" indicates a success in the execution of the program. But for this failure scenario we can use either a non-zero positive integer or a simpler "exit(EXIT_FAILURE)" to indicate the program suffered a failure. One more missing item is the return value for the main() function in mq_send.c file.This program should return an integer (indicating a success or failure) when it exits from the while() loop.
@dextutor
@dextutor Жыл бұрын
As you rightly pointed out its an introductory program for beginners, so the things are kept simple and minimal.
@ritikamahanta
@ritikamahanta 3 жыл бұрын
Is this complete playlist of os ..
@dextutor
@dextutor 3 жыл бұрын
Yes
@aryantnigam2246
@aryantnigam2246 3 жыл бұрын
Sir are you from lpu?
Deadlock in OS || Program to simulate Deadlock || C Program
13:01
Program for Inter-Process Communication using shared memory
14:10
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
How to have fun with a child 🤣 Food wrap frame! #shorts
0:21
BadaBOOM!
Рет қаралды 17 МЛН
I'VE MADE A CUTE FLYING LOLLIPOP FOR MY KID #SHORTS
0:48
A Plus School
Рет қаралды 20 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
Communicating between processes (using pipes) in C
14:00
CodeVault
Рет қаралды 297 М.
What is a Message Queue?
15:38
IBM Technology
Рет қаралды 101 М.
IPC: To Share Memory Or To Send Messages
14:15
Core Dumped
Рет қаралды 119 М.
What are Message Queues? | BullMQ Queues NodeJS
44:12
Piyush Garg
Рет қаралды 44 М.
Linux Internals : Interprocess Communication
24:17
DJ Ware
Рет қаралды 45 М.
Sending and Handling Signals in C (kill, signal, sigaction)
5:52
Jacob Sorber
Рет қаралды 198 М.
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН