【DSP开发】shared memory VS mailbox
2016-06-24 13:39
423 查看
Hello,
Hi everyone,
I have a simple question. Could anyone explain to me the difference between Mailboxes and Shared Memory?
A “Shared memory” (shm) is some portion of memory that you can share between process and threads. Like a malloc, you have a fixed size memory area, and you can do nearly what you want with. (Reading of writing)
A Mailbox is more like a pipe. You push data (messages) on the pipe of indeterminate size (the mailbox as a fixed size that you can store multiples messages, but not exceeding the size of the mailbox)
Classic mailboxes are “One consumer multiple producers” but some types of mailbox allow to have multiple consumers (but I not sure this is a good idea) and you can put priority on messages with some other sort of mailboxes. You have too the ability to suspend a task (thread or process) on reading a mailbox, allowing it to wait for a new message.
Am I right, that both are possibilities for two or more tasks to exchange data?
Yes but not is the same way (as explained above.) The use of each depends on what you want to do.
If it for sharing global variables, shm is, as for me, the better way, if it for send private data, or give orders, Mailbox (or pipe) are the better.
Will a message send to a mailbox still be in the mailbox after another task read it?
No
Greetings from Germany,
Martin
Greetings from South of France, and have a good day playing with IPC :)
Manoel
Hi everyone,
I have a simple question. Could anyone explain to me the difference between Mailboxes and Shared Memory?
A “Shared memory” (shm) is some portion of memory that you can share between process and threads. Like a malloc, you have a fixed size memory area, and you can do nearly what you want with. (Reading of writing)
A Mailbox is more like a pipe. You push data (messages) on the pipe of indeterminate size (the mailbox as a fixed size that you can store multiples messages, but not exceeding the size of the mailbox)
Classic mailboxes are “One consumer multiple producers” but some types of mailbox allow to have multiple consumers (but I not sure this is a good idea) and you can put priority on messages with some other sort of mailboxes. You have too the ability to suspend a task (thread or process) on reading a mailbox, allowing it to wait for a new message.
Am I right, that both are possibilities for two or more tasks to exchange data?
Yes but not is the same way (as explained above.) The use of each depends on what you want to do.
If it for sharing global variables, shm is, as for me, the better way, if it for send private data, or give orders, Mailbox (or pipe) are the better.
Will a message send to a mailbox still be in the mailbox after another task read it?
No
Greetings from Germany,
Martin
Greetings from South of France, and have a good day playing with IPC :)
Manoel
相关文章推荐
- Repairing a Road
- 【DSP开发】mailbox的使用
- grails调用groovy脚本
- Claims Based Authentication and Token Based Authentication和WIF
- 给DIY的服务器添加raid驱动
- LeetCode 220. Contains Duplicate III
- 编译busybox时使用make menuconfig命令出现下列问题:recipe for target 'scripts/kconfig/lxdialog/checklist.o' failed
- PaintCode 绘图(一)
- Canvas和Paint的使用小结
- 指针数组--main参数
- 【leetcode】219. Contains Duplicate II
- 翻译HAIP相关问答
- 基于zookeeper、连接池、Failover/LoadBalance等改造Thrift 服务化
- Keychain Access中开发证书和秘钥的关系
- 80老翁谈人生(14):迎接2016中国人工智能大会的召开!
- Maven错误问题解决 Failure to transfer com.thoughtworks.xstream:xstream:jar:1.3.1 from https://repo.maven
- 开发错误记录11:git报错 fatal:open /dev/null or dup failed: No such file or directory
- OpenCV的waitkey不起作用
- TurboMail邮件系统与中国外汇交易中心合作
- leetcode 217 Contains Duplicate