Mailboxes and queues examples?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

kermitas
Posts: 17
Joined: Wed Mar 21, 2012 9:39 pm

Mailboxes and queues examples?

Post by kermitas »

Hello everybody, hello Giovanni :).

If there are no stupid questions ... I wonder to know where can I find mailboxes and queues usage examples??

Thanks:)
Arthur.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Mailboxes and queues examples?

Post by Giovanni »

Hi Arthur,

You may look into the test code under ./test, you can find there examples for all kernel functions, feel free to ask questions on the forum if you have any doubt. Device drivers are also good examples for Queues, Semaphores and Events.

Consulting documentation while browsing the code is also a good idea. :)

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Mailboxes and queues examples?

Post by Giovanni »

Ah, for mailboxes look at the "IRQ_STORM" demos under ./testhal, MBs are used heavily there.

Giovanni
utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: Mailboxes and queues examples?

Post by utzig »

Hi,

The test/ directory in the sources root has examples for most kernel features. In specific you should look to test/testmbox.c and test/testqueues.c.

Fabio Utzig
kermitas
Posts: 17
Joined: Wed Mar 21, 2012 9:39 pm

Re: Mailboxes and queues examples?

Post by kermitas »

Thans :).

I didn't know where to start.

I am thinkig about something similar to actors model - like in Scala (www.akka.io) or Erlang:
- each actor has it own mailbox
- actors exchange messages
- actors uses thread pool
- if actor receive message ask thread pool if there is free thread, if yes it uses it to proces all messages from mailbox
- thread pool can have for example: small number of threads in the night and grow during the day to proces users demand
- scheduler can send registered message periodically to actor to "wake it up" and to do some cyclic work; scheduler can also send message once at defined time

I like this separation between actors and threads. You can have many actors and only one-or-two threads.

What you think about it? Do you know actors model? :)

...but to write all of this I have to learn a lot about ChibiOS :)).
Arthur.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Mailboxes and queues examples?

Post by Giovanni »

Hi,

Look at that IRQ_STORM demo, there is a single thread in multiple instances, each instance has its own mailbox and all instances send messages each other, very similar to what you described.

It is meant as a stress test.

Giovanni
kermitas
Posts: 17
Joined: Wed Mar 21, 2012 9:39 pm

Re: Mailboxes and queues examples?

Post by kermitas »

Giovanni wrote:Hi,

Look at that IRQ_STORM demo, there is a single thread in multiple instances, each instance has its own mailbox and all instances send messages each other, very similar to what you described.

It is meant as a stress test.

Giovanni


Yes, I am anaylzing IRQ_STORM demo right now.

In case of future questions - should I split them in to many simple-to-answer questions posted here, in "support" forum?

Thanks,
Arthur.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Mailboxes and queues examples?

Post by Giovanni »

Focused questions are more efficiently answered of course.

Giovanni
User avatar
sabdulqadir
Posts: 49
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 13 times
Been thanked: 4 times

Re: Mailboxes and queues examples?

Post by sabdulqadir »

utzig wrote:Hi,

The test/ directory in the sources root has examples for most kernel features. In specific you should look to test/testmbox.c and test/testqueues.c.

Fabio Utzig


Have the structure changed? Could not find these in the current distribution. Or am i not looking at the correct stuff (https://github.com/ChibiOS/ChibiOS/tree/master/test) ?

Thanks
AQ
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Mailboxes and queues examples?

Post by Giovanni »

Hi,

It is \test\rt\source\test now.

Giovanni
Post Reply