-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add overridable wait hook #1
base: sleep_api
Are you sure you want to change the base?
Conversation
Provide partial RTOS API for bare metal builds - things that can be done in a single threaded environment. Allows more code to work in both RTOS and bare metal builds without change, and in particular gives easy access to the ability to efficiently wait for something occurring in interrupt. Available in bare-metal: * ThisThread * osThreadFlagsSet to set flags on main thread (can be set from IRQ) * EventFlags (can be set from IRQ) * Semaphores (can be released from IRQ) * Mutex (dummy implementation) Not useful: * ConditionVariable (could only be signalled from 2nd thread) * RtosTimer (calls in a second thread context) * Thread Unimplemented: * Mail, Queue, MemoryPool Possible future work: * ConditionVariableCS to act as IRQ signalled ConditionVariable
Switch from CMSIS-RTOS to mbed C++ API, which are available in bare metal build. Other minor tidies, like removing unnecessary volatile.
Revert back to older behaviour where we hold deep sleep lock only while timing a sleep. Previous version was a speed optimisation, but broke some tests.
For your use case, wouldn't you actually want to replace the hal sleep? (Like the override_console replaces the target_override_console). The replacement would of course be free to pass the call onto the hal/target, conditionally. For example, if you do some of your work, decide it's now finished so you need to signal a thread, you would not want to actually go into sleep, you'd want to leave idle immediately. Also, unfortunately, sleep is entered with interrupts disabled in a normal idle situation - race-free checking of "do I need to sleep" requires this. So this approach isn't going to quite work - it's too low level. But I think we can slot this into the ARMmbed#10104 "do_sleep" framework, into the "preparation" section which always has interrupts enabled, prior to making the actual IRQ off/sleep bit. That would also handle the "not idle any more" case, as it would precede the "sleep predicate" check. |
Fix LWIP warning issues found by Coverity scan lwip_dns.c in function: dns_add_interface_server CID 1399051 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)10. buffer_size_warning: Calling strncpy with a maximum size argument of 6 bytes on destination array new_interface_server->interface_name of size 6 bytes might leave the destination string unterminated. line 434 strncpy(new_interface_server->interface_name, interface_name, INTERFACE_NAME_MAX_SIZE); lwip_ip4_frag.c in function: ip_reass_free_complete_datagram CID 1373164 (#1 of 1): Dereference after null check (FORWARD_NULL)7. var_deref_model: Passing null pointer prev to ip_reass_dequeue_datagram, which dereferences it. [show details] line 209 ip_reass_dequeue_datagram(ipr, prev); lwip_ip4_frag.c in function: ip_reass CID 1373163 (#1-2 of 2): Dereference after null check (FORWARD_NULL)38. var_deref_model: Passing null pointer ipr_prev to ip_reass_dequeue_datagram, which dereferences it. [show details] line 663 ip_reass_dequeue_datagram(ipr, ipr_prev); lwip_api_msg.c in function: lwip_netconn_do_connected CID 1373162 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)10. var_deref_model: Passing null pointer op_completed_sem to sys_sem_signal, which dereferences it. [show details] line 1336 sys_sem_signal(op_completed_sem);
One more thought - what sort of work are we talking about here? Very short-running, or long-running? There's a fundamental choice to make - is this hook run
b) is a bit scary - it's a priority inversion of the idle thread. Would be fine for something very short-running, but if you're intending to do real work, it seems like you need a). Which is effectively the "idle hook" we already have, except we don't have a nice chaining mechanism to let you move on to standard sleep. |
1231f84
to
0ca5c57
Compare
ab49061
to
ed4bf52
Compare
Update CMSIS-pack info for STM32G-family
Signed-off-by: PARKJIHOON <[email protected]>
From ARMmbed#10693
Changed to fit into ARMmbed#10104.
I understand hal_sleep exists, and it's useful for the target, but it can't be used to catch sleep calls by the application (similar to mbed_target_override_serial vs mbed_override_serial).
While we're on the topic of naming, I went with mbed_override_sleep_hook to match the above serial names, but am open to other suggestions.
This is a follow from ARMmbed#10693