Saturday, December 14, 2013

Message buffer vs Mail box: Creation

① Difference between Message buffer and Mailbox
 
Mail box:
 
You have your own suitcase with a handle. You dump your things in that and pass it to us. We will use the handle to put it again in the roller.
 
"Mailbox suitcase"
 
Message Buffer:
 
Just give your message! We have space to share it.
 
"Message buffer notice board"
 
A message buffer transfers a variable-sized message through copying. It is different from a data queue in that it transfers variable-sized messages. It is different from a mailbox in that it copies the messages. A message buffer is assumed to be implemented as a ring buffer.
 
Message buffer is exactly same as data queue with Send & Receive wait queues, Prioritized sending, FIFO Receive, Ring buffer, data copy, synchronous message passing. Differencea are variable sized data unit which may need additional management data in the ring buffer and forced send is not there.
 
② ITRON implementation of cre_mbf
 
ER cre_mbf(ID mbfid, T_CMBF *pk_cmbf)
{
        Check context. If called from ISR,
                return E_CTX;
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Allocate memory for the data queue and send task queue;
        (for data queue, each element is sizeof(void pointer))
        Initialize the data queue structure;(data queue structure is as follows)

        In this function, start, head, tail parameters are initialized to start address
        end parameter is initialized to end address
        Counter for number of valid data elements is initialized to zero
        Initialize the receiving task waiting queue structure;(Only FIFO order. so,)
                Initialize queue as follows:
                ┏━━━━━┯━━━━━━┓
                ┃Queue   │Queue     ┃
                ┃[0]     │Tail       ┃
                ┗━━━━━┷━━━━━━┛
        Initialize the sending task waiting queue structure;
        If (tasks are queued in FIFO order)
                Initialize queue as follows:
                ┏━━━━━┯━━━━━━┓
                ┃Queue   │Queue     ┃
                ┃[0]     │Tail       ┃
                ┗━━━━━┷━━━━━━┛
        else (tasks are queued as priority based)
                Initialize as follows:
                ┏━━━━━━━━┯━━┯━━━━┯━━━━━━┓
                ┃Priority0      │1   │Max   │Queue    ┃
                ┃            │    │Pri    │Tail       ┃
                ┗━━━━━━━━┷━━┷━━━━┷━━━━━━┛
        Exit critical section (Interrupt Restore)
        return E_OK;
}
 

No comments: