Where is the contents of the message queue stored?

When using POSIX message queues, I noticed that several files were created on the file system with the name I created the queues. My questions:

Q1. Do message queues queue messages on the hard drive, not RAM?

Q2. If so, shouldn't it be very slow to implement as it includes HardDisk?


Edit:

I read this in the book "Linux Programming Interface" :

On Linux, POSIX message queues are implemented as i-nodes in a virtual file system, and message queue descriptors and descriptions of open message queues are implemented as file descriptors and descriptions of open files, respectively. However, these are implementation details that are not required by SUSv3 and are not implemented on some other UNIX implementations.

Even if it is VFS, it is still stored on the hard drive, right?

With this information in mind, can anyone comment on the second question now? (and / or First also, if there is something to add)

+6
source share
2 answers

The link below may provide some clarity on the first question http://man7.org/linux/man-pages/man7/mq_overview.7.html

As for the second question, of course, the file-based queue will be slower than the memory-based one. But this may not be as slow as some operations with random access to files, because it is optimized and implemented specifically for queuing.

+6
source

I read the link: https://zinascii.com/2014/a-posix-queue-implementation.html and I see that the message queue (POSIX) is created by the mmap () function, which means that the queue data is stored in RAM outside kernel space. Can anyone confirm?

0
source

All Articles