Skip to content
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

Fix mbed-client behaviour in irq contexts #2530

Closed
wants to merge 2 commits into from

Conversation

geky
Copy link
Contributor

@geky geky commented Aug 23, 2016

Should resolve ARMmbed/mbed-os-example-client#75

mbed-client defines M2MConnectionHandlerPimpl::socket_event for handling the event passed through the UDPSocket::attach function. Unfortunately, the previous implementation contained both a tr_debug call and malloc call that were unacceptably long-running and caused UART bytes to be dropped.

This issue was not unnoticable in lwip's implementation. We could update lwip to dispatch events in a critical section, insuring correct behaviour, although this would introduce unnecessary jitter in existing code.

cc @yogpan01, Should I be making this pr to https://github.com/armmbed/mbed-client-classic as well? Let me know how to best submit patches for this code.

During debugging, the tr_debug call in M2MConnectionHandlerPimpl::socket_event
took an unacceptable amount of time to complete, causing bytes traveling through
the esp8266's serial connection to be dropped.

This was unnoticable in lwip's network-socket implementation due to not
occuring in an interrupt context.
Replaced malloc calls in interrupt contexts with allocations from a
local memory pool using rtos::MemoryPool
@@ -310,9 +312,7 @@ int8_t M2MConnectionHandlerPimpl::connection_tasklet_handler()

void M2MConnectionHandlerPimpl::socket_event()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this called from irq context? then it make sense to minimize code here, like remove trace and allocation related calls,,, but how faster this memory_pool really are? any numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't measured their performance, it would be interesting to see the numbers.

Although the issue isn't with average performance, but with jitter. As a simple linked-list, the memory pool garuntees constant runtime, where malloc may have an outlier (in the case of coalescing lazily for example) but be faster on average. This outlier may disrupt interrupt based communication.

@jupe
Copy link
Contributor

jupe commented Aug 24, 2016

I think this should be done only for mbed-client-classic..

@geky
Copy link
Contributor Author

geky commented Aug 24, 2016

Sorry, I don't quite understand. Is this pr fine as is?

@yogpan01
Copy link
Contributor

@geky Any fix PR on mbed-client-classic or mbed-client should be done on those repos directly.
mbed-os only has copy of mbed-client components and these fixes will be lost if done directly on mbed-os and not through the direct repos.

@geky
Copy link
Contributor Author

geky commented Aug 24, 2016

@yogpan01, ok thanks for the clarification. I'll move this over to mbed-client-classic.

Are there bulk prs to bring mbed-os up to date?

@yogpan01
Copy link
Contributor

@geky We will be doing regular patch updates on all our components and sending those PRs to mbed-os so they can land up in bi-weekly mbed-os releases. Like this one is lined up for next mbed-os release candidate #2527

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2016

@geky Closing this as I understood correctly all the messages above. If not, please reopen

@geky
Copy link
Contributor Author

geky commented Aug 24, 2016

Moved to ARMmbed/mbed-client-classic#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't register mbed-client object successfully through WiFi
4 participants