-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Osal queue timeout #1440
Osal queue timeout #1440
Conversation
…oth pending for event queue with timeout of 1 ms
Please set a configurable timeout for each queue (something like CFG_TUSB_TMO_xxx). Not a hard value. Currently there is no timeout so I managed it in the OSAL layer: sometimes 0 and other times infinite. The value 1 is not practical because it leads to useless context switches when there is nothing to do, and a waste of time if we wanted 0. Moreover, if tud_task() is called by an interrupt, it is forbidden to have a timeout! |
yeah, that makes sense on the context switch overhead, the tud_task() should take an timeout as argument instead. Though regarding ISR, tud_task() must not be called within ISR when using within an RTOS, current mutex, queue API does not take this into account (yet) |
…eout and in_isr also allow exit tud_task,tuh_task after processing all events for running other background task for user
@Nikitarc thank you for your feedback, I have updated the pr to add new API tud_task_ext() and tuh_task_ext() that takes timeout_ms and in_isr as parameters. The task will exit once processed all events so that thread can still be shared with other background function if needed. |
I see you add timeout_ms, and specify 0xFFFFFFFF = wait forever. |
there is one OSAL_TIMEOUT_WAIT_FOREVER, you could also use the UINT32_MAX as well. Line 41 in 55a5fd5
|
Thanks for the info on OSAL_TIMEOUT_WAIT_FOREVER. |
osal.h isn't considered as public header, I don't have time right now to change it.I intend to use -1 with int, but decide 0xFFFFFFFF isn't too bad. This may change in the future. |
_osal.h isn't considered as public header Anyway, we are not talking about application code, but about USB stack code. In my opinion the USB stack code should use its own definitions. |
Describe the PR
timeout in 1 mswait forever on event queue, but will exit once processed all events to allow RTOS thread to be shared with other background work e.g cdc flush().timeout_ms
andin_isr
(not yet supported)@dhalbert