native: optionally exit() after last thread has ended

Used when compiled with NATIVE_AUTO_EXIT defined.
This commit is contained in:
Kaspar Schleiser 2014-04-04 08:21:23 +02:00
parent 3903b8add2
commit 900db3436a
2 changed files with 15 additions and 0 deletions

View File

@ -128,3 +128,11 @@ is established.
Socket redirection is only available when the uart module has been Socket redirection is only available when the uart module has been
compiled in. compiled in.
COMPILE TIME OPTIONS
====================
Compile with
CFLAGS=-DNATIVE_AUTO_EXIT make
to exit the riot core after the last thread has exited.

View File

@ -151,6 +151,13 @@ void isr_cpu_switch_context_exit(void)
void cpu_switch_context_exit() void cpu_switch_context_exit()
{ {
#ifdef NATIVE_AUTO_EXIT
if (num_tasks <= 1) {
DEBUG("cpu_switch_context_exit(): last task has ended. exiting.\n");
exit(EXIT_SUCCESS);
}
#endif
if (_native_in_isr == 0) { if (_native_in_isr == 0) {
dINT(); dINT();
_native_in_isr = 1; _native_in_isr = 1;