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

Eventloop in main thread to master #6186

Merged
merged 2 commits into from Feb 27, 2018

Conversation

Projects
None yet
6 participants
@TeroJaasko
Contributor

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

TeroJaasko added some commits Dec 1, 2017

nanostack-hal: modify eventloop to allow running it in a main thread
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.
nanostack-hal: remove connection from event loop init and dispatch th…
…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 0xc0170 requested a review from kjbracey-arm Feb 26, 2018

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Feb 26, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Feb 26, 2018

/morph build

@mbed-ci

This comment has been minimized.

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

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@cmonr cmonr added ready for merge and removed needs: CI labels Feb 27, 2018

@kjbracey-arm kjbracey-arm merged commit d24c7c4 into ARMmbed:master Feb 27, 2018

18 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
mbed-ci-generic Build finished.
Details
travis-ci/docs/ Local docs testing has passed
Details
travis-ci/events/ Local events testing has passed
Details
travis-ci/littlefs/ Local littlefs testing has passed
Details
travis-ci/mbed2-ATMEL/ Local mbed2-ATMEL testing has passed
Details
travis-ci/mbed2-MAXIM/ Local mbed2-MAXIM testing has passed
Details
travis-ci/mbed2-NORDIC/ Local mbed2-NORDIC testing has passed
Details
travis-ci/mbed2-NUVOTON/ Local mbed2-NUVOTON testing has passed
Details
travis-ci/mbed2-NXP/ Local mbed2-NXP testing has passed
Details
travis-ci/mbed2-SILICON_LABS/ Local mbed2-SILICON_LABS testing has passed
Details
travis-ci/mbed2-STM/ Local mbed2-STM testing has passed
Details

@sg- sg- removed the ready for merge label Feb 27, 2018

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