Skip to content

Eventloop in main thread to master #6186

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

Merged

Conversation

TeroJaasko
Copy link
Contributor

@TeroJaasko TeroJaasko commented Feb 23, 2018

Description

This has the same content as ARMmbed/mbed-os-confidential-m#7 and #5752, just the target repo and branch are different.

Copypasta from commit:
--8<--8<--8<--8<--8<
The separate eventloop thread may not be necessary on all uses, as one
can use the existing main thread for event dispatching. Add a
conditional nanostack-hal.event-loop-dispatch-from-application, which
disables the thread creation.

Note: the ns_hal_init must be ran from the same thread which will be
used to execute the event loop later.
--8<--8<--8<--8<--8<

By removing the separate event loop thread, one saves about 6KB of RAM in mbed cloud client example side.

Status

READY

Migrations

Unless one sets the "nanostack-hal.event-loop-dispatch-from-application" to true, the existing behavior is not changed.

NO

Related PRs

Todos

  • Tests
  • Documentation

Deploy notes

Steps to test or reproduce

Testing can be done by adding following code to the end of main(), where one has already initialized the event loop and the application code:

#if MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_DISPATCH_FROM_APPLICATION

    printf("Starting eventloop..\n");
    eventOS_scheduler_mutex_wait();
    // this will block for ever
    eventOS_scheduler_run();

#else
<normal wait-forever code>
#endif

The separate eventloop thread may not be necessary on all uses, as one
can use the existing main thread for event dispatching. Add a
conditional nanostack-hal.event-loop-dispatch-from-application, which
disables the thread creation.

Note: the ns_hal_init must be ran from the same thread which will be
used to execute the event loop later.
…read

The thread flag signaling mechanism is problematic if a separate event
loop thread is not used. The problem is, that one needs to know the
thread id of the loop dispathcer, and that knowledge can be derived
only from the caller thread of the initialization function.

Remove the magic connection from caller thread to dispatcher thread
by using event flags instead of thread flags on signaling. As the
event flags require the massive amount 20 bytes of RAM whereas
thread flags requires none, keep the code behind flag.
@0xc0170
Copy link
Contributor

0xc0170 commented Feb 26, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 26, 2018

Build : SUCCESS

Build number : 1256
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6186/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Feb 26, 2018

@mbed-ci
Copy link

mbed-ci commented Feb 26, 2018

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

Successfully merging this pull request may close these issues.

6 participants