Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What have you used sysv/posix message queues for?

Tags:

c

posix

ipc

I've never seen any project or anything utilizing posix or sysv message queues - and being curious, what problems or projects have you guys used them for ?

like image 950
leeeroy Avatar asked Feb 28 '10 16:02

leeeroy


2 Answers

I had a series of commands that needed to be executed in order, but the main program flow did not depend on their completion so I queued them up and passed them to another process via a System V message queue to be executed independently of the main program. Since message queues provide an asynchronous communications protocol, they were a good fit for this task.

To be honest, I used System V message queues because I had never used them before and I wanted to. I'm sure there are other IPC methods I could have used.


It's been a while since I've done any real VxWorks programming, but you can also find message queues used in VxWorks applications. According to the VxWorks Application Programmer's Guide (Google search), the primary intertask communication mechanism within a single CPU is message queues. VxWorks uses two message queue subroutine libraries (POSIX and VxWorks).

like image 149
jschmier Avatar answered Nov 15 '22 00:11

jschmier


I once wrote a text-mode I/O generator utility that had one thread in charge of updating the UI and a number of worker threads to do the actual I/O work. When a worker thread completed an I/O, it sent an update message to the UI thread. I implemented this message system using a POSIX message queue.

Why implement it like this? It sounded like a good idea at the time, and I was curious about how they worked. I figured I could solve the problem and learn something at the same time. There were many different techniques I could have used, and I don't suppose there was any profound reason why I chose this technique. I didn't realize it until later, but I was glad I used a POSIX queue when I had to port the utility to another system (it was also POSIX compliant, so I didn't have to worry about porting external libraries to get my app to run).

like image 25
bta Avatar answered Nov 14 '22 23:11

bta