Hello,
I am currently using ChibiOS/RT for a small project.
I am trying to build a service based architecture, where I have multiple different "service" threads for different hardware and software parts (like Display, HID, Log, etc.)
For communication I use chMsgSend and chMsgRelease, so synchronous messages.
I have a main application running with the highest priority and the service threads all running in the same priority with round-robin scheduling enabled.
The problem is: When I send a message with chMsgSend and return with chMsgRelease, the service thread still uses up its while timeslot (about 10ms or more) before it switches to the higher priority main application thread again. chMsgRelease returns immediately but also does not switch threads to the higher priority thread.
Question: Why is this happening? From reading the code, the RTOS should sleep the current thread and immediately switch to the receiver thread when chMsgSend is called, and immediately return from the service thread and switch to the highest priority thread (my main application thread) when chMsgRelease is called.
I uploaded a https://gist.github.com/birdboat00/e9af ... 0430ad1b85 "pseudo-code" example on Gist.
Thank you all a lot!
Maybe I am just misunderstanding how RTOSes schedule and i may need another scheduling algorithm.
But I would be really grateful if you could atleast give me a bit of a direction of what I may be understanding or doing wrong.
Scheduling and Synchronous messages
- Giovanni
- Site Admin
- Posts: 14565
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1112 times
- Been thanked: 937 times
- Contact:
Re: Scheduling and Synchronous messages
Hi,
The quantum should not be relevant, the 10mS should be the message processing time by the threads.
Try measuring around the "processing", chMsgSend() waits for the whole time spent between chMsgWait() and chMsgRelease().
Scheduling is done by priority, at equal priority round robin occurs, it could be a good idea for determinism to give to the "server" threads +1 and +2 priorities.
Giovanni
The quantum should not be relevant, the 10mS should be the message processing time by the threads.
Try measuring around the "processing", chMsgSend() waits for the whole time spent between chMsgWait() and chMsgRelease().
Scheduling is done by priority, at equal priority round robin occurs, it could be a good idea for determinism to give to the "server" threads +1 and +2 priorities.
Giovanni
Re: Scheduling and Synchronous messages
Hi Giovanni,
the processing part, so between chMsgWait and chMsgRelease takes about 1-2 milliseconds or even less.
Best Regards
Sebastian
the processing part, so between chMsgWait and chMsgRelease takes about 1-2 milliseconds or even less.
Best Regards
Sebastian
- Giovanni
- Site Admin
- Posts: 14565
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1112 times
- Been thanked: 937 times
- Contact:
Re: Scheduling and Synchronous messages
It could be the 2 processing parts combined, for sure it does not spend time by itself.
Giovanni
Giovanni
Who is online
Users browsing this forum: No registered users and 11 guests