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: Serial Application


You could use the cyg_mbox_...() functions in conjunction with an array of
your structures initially organised in a linked list, maintaining a variable
which points to the head of this linked list (call this the 'free pool').

To send from Thread A to Thread B, Thread A would remove a structure from
(the head of) the free pool, fill its contents, then send to Thread B using
cyg_mbox_put(), with the pointer to this structure as the 'item' in
cyg_mbox_put().

Thread B would use cyg_mbox_get() (or cyg_mbox_timed_get()) to retrieve the
pointer value, which it would then dereference to get to the contents. Once
Thread B has finished with it, it can either reclaim it directly to the free
pool, in which case you would need a mutex to ensure only one thread can
access the free pool at any one time, or you could set up a mailbox to
return the pointer back to Thread A, which would then reclaim it; in this
case you wouldn't need mutex protection if only Thread A was ever going to
access the free pool.

Note the number of structures in your free pool should match the number of
entries in the mailbox, which is specified by
CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE, and defaults to 10, I believe.

Hope this helps

Robert Cragie
Design Engineer
Jennic Ltd.
Furnival Street
Sheffield
S1 4QT
United Kingdom
Tel: +44 (0) 114 281 4512
Fax: +44 (0) 114 281 2951
mailto:rcc@jennic.com
http://www.jennic.com

> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Carlos
> Camargo
> Sent: 27 April 2001 11:30
> To: ecos-discuss@sources.redhat.com
> Subject: RE: [ECOS] Serial Application
>
>
> Hi all..
>
> My problem is:
>
> I use mbox to transfer data between two threads, now i
> able to send only int data.
>
> I want send complex data with mbox, i define a struct
> (  more complex that the example in my previous mail),
> but i can't put or get messages of struct type.
>
> Thanks
>
> Carlos camargo
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/


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