This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: message box.


Hi Fabrice

I think the best way of thinking about message boxes is to consider
the void * item as four bytes. You can do what you want with those
four bytes. It could be a pointer to somewhere into memory, an
integer, etc. When you do cyg_mbox_put(mbox,item), those four bytes
are copied into the mbox. When you do cyg_mbox_get, those four bytes
are returned. 

The most common use is to have item as a pointer to some structure in
memory. You use the mbox to inter process communication, one thread
saying to another, "Hi, have a look at this memory, there is something
interesting there for you." Both the send and the receiver have to
know what the memory means, its layout, length, if it needs mutex
protection for modification etc. 

You asked if the sender modifies what the pointer points to betweeen
the put and get, the getter sees? Yes it does. It also sees changes
after the get so you could use this for setting up a shared memory
between threads.

Hope this helps

        Andrew        


> Hi,
> 
> about message box:
> 
> when I cyg_mbox_put an item, there is no copy of the item in a queue, right?
> It is only the pointer to the item that is added to the queue, Right?
> 
> So when I cyg_mbox_get the item, There's no copy and i just get the pointer
> I passed , Right?
> So that if the sender modified the content of the item after the 'put' be
> before the 'get' the content of the message is modified.
> And so that there is way for the receiver to know the lenght of the message,
> 
> Is that all right?
> 
> Thanks
> 
> A+
> -- 
> Fabrice Gautier
> fabrice_gautier@sdesigns.com 
>  
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]