zoukankan      html  css  js  c++  java
  • 【DSP开发】shared memory VS mailbox

    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

  • 相关阅读:
    CS academy Binary Flips(dp)
    [POJ 1637] Sightseeing tour(网络流)
    Codeforces 346D Robot Control(01BFS)
    BZOJ 2069: [POI2004]ZAW(Dijkstra + 二进制拆分)
    驱动之SPI,UART,I2C的介绍与应用20170118
    USB驱动之CDC类的介绍与应用20160905
    uCOS-II之移植20160823
    java之面向对象20160818
    Java之基础20160806
    Android之框架20160721
  • 原文地址:https://www.cnblogs.com/huty/p/8518498.html
Copyright © 2011-2022 走看看