[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


previous: >>108836750

#define __NR_mq_open                240
#define __NR_mq_unlink 241
#define __NR_mq_timedsend 242
#define __NR_mq_timedreceive 243
#define __NR_mq_notify 244
#define __NR_mq_getsetattr 245

https://man7.org/linux/man-pages/man2/mq_open.2.html
https://man7.org/linux/man-pages/man2/mq_unlink.2.html
https://man7.org/linux/man-pages/man2/mq_timedsend.2.html
https://man7.org/linux/man-pages/man2/mq_timedreceive.2.html
https://man7.org/linux/man-pages/man2/mq_notify.2.html
https://man7.org/linux/man-pages/man2/mq_getsetattr.2.html
https://man7.org/linux/man-pages/man7/mq_overview.7.html

tl;dr:
posix message queues

another set of syscalls that aren't actually intended to be used on their own, just to implement a library.
> Never call it unless you are writing a C library!
like geeze okay...
i once again don't have much to add to the discussion here. it's one of a million different IPC apis, and i couldn't even begin to tell you why you might prefer it over any other option. maybe some anon knows?

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
>>
>>108844215
tf did i just read
>>
bampu
>>
they require less overhead than sockets. Much easier to get started with.
Eventually you will probably find out that you actually need bidirectionality. I hope for you that when that day comes, you didn't couple your code against the api and its assumptions too tightly.
tdh at this point you can probably just make LLM generate you the bidir negation layer on top of mqs if you only need it at very few occasions
>>
>>108845510
i mean, two pipe pairs is ezpz for bidirectional IO. when would you ever need more?
>>
>>108845674
the usecase is n-producers-single-consumer
the kernel will handle serialization and buffering of messages for you, you can even keep your consumer single threaded.
and you don't even need to fork for it.

For some narrow set of constraints, namely unidirectional packets, it is the superior option
>>
>>108845773
ahhh, see now that does make sense
>>
>>108845510
>they require less overhead than sockets.
How much less than AF_UNIX which bypasses the network stack and is basically two pipes already?
>>
>>108844215
# CONFIG_POSIX_MQUEUE is not set
>>
>>108845773
sounds fishy. compare it to dgram unix socket.
can you use mqd_t with poll? because that's another readiness mechanism that you cant mix with others.

you can also have bidirectional dgram unix socket btw
>>
>>108849651
All sockets are bidirectional. What would be the point of a unidirectional socket?
>>
>>108850043
it's not worth losing sleep asking "what's the point of X" when it comes to posix
some things are just unknowable
>>
>>108850063
I'm not questioning POSIX, I'm questioning you. >>108849651
>you can also have bidirectional (...) socket
>>
>>108848709
I was being imprecise here. I meant code overhead, instead of computing resource overhead.
You only need mq_open to create (with O_CREAT flag) and open the message queue. With sockets, the dance to set them up is a bit more involved. You need at least some boilerplat to initialize sockaddr_un. But at least for datagram sockets you don't need to have different fds for the socket and the sessions.
also, message queues have good performance and can be faster than unix domain sockets for at least some payload sizes:
https://stackoverflow.com/questions/50171306/message-queue-vs-tcp-ip-socket-which-ipc-is-faster-in-linux
Note that because posix message queues use a different namespace than other file (they all live in /dev/mqueue), another user on the system might be able to ddos you by creating a message queue with the same name. To mitigate issues like this when working on a potentially hostile systems, posix message queues probably require more code, because with sockets or fifos you can just create these files in your home directory.
>>108849651
>can you use mqd_t with poll?
yes, posix mqueues are mostly like regular files, even goodies like O_NONBLOCK work.
This is not true for the old SystemV message queues afaik.
>>
>>108850043
I mentioned it because datagram unix sockets don't work bidirectioannly by default, you have to do a extra step on client side to make it work



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.