diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-28 21:42:18 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-28 21:42:18 +0000 |
commit | 94c7babe23d72a1e379da0cf0aab32fcf9fadcf3 (patch) | |
tree | eedc930a4ed4a1108c87cae26d3fcda7e411dd1f /apps | |
parent | 405c2b328ff4cd571bb9e464541b4d297b18f93d (diff) | |
download | px4-nuttx-94c7babe23d72a1e379da0cf0aab32fcf9fadcf3.tar.gz px4-nuttx-94c7babe23d72a1e379da0cf0aab32fcf9fadcf3.tar.bz2 px4-nuttx-94c7babe23d72a1e379da0cf0aab32fcf9fadcf3.zip |
atexit() functions now called when task killed by task delete; For MCUs with <= 64Kb of SRAM, CONFIG_MM_SMALL can be defined to reduce the memory allocation overhead
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3648 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rw-r--r-- | apps/examples/ostest/barrier.c | 10 | ||||
-rw-r--r-- | apps/examples/ostest/ostest.h | 14 | ||||
-rw-r--r-- | apps/examples/ostest/posixtimer.c | 8 | ||||
-rw-r--r-- | apps/examples/ostest/prioinherit.c | 28 | ||||
-rw-r--r-- | apps/examples/ostest/sighand.c | 22 | ||||
-rw-r--r-- | apps/examples/ostest/timedmqueue.c | 6 | ||||
-rw-r--r-- | apps/examples/ostest/timedwait.c | 6 |
7 files changed, 42 insertions, 52 deletions
diff --git a/apps/examples/ostest/barrier.c b/apps/examples/ostest/barrier.c index c88e1bed1..da1301dc3 100644 --- a/apps/examples/ostest/barrier.c +++ b/apps/examples/ostest/barrier.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/ostest/barrier.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -77,6 +77,7 @@ static void *barrier_func(void *parameter) printf("barrier_func: Thread %d calling pthread_barrier_wait()\n", id); + FFLUSH(); status = pthread_barrier_wait(&barrier); if (status == 0) { @@ -95,11 +96,13 @@ static void *barrier_func(void *parameter) printf("barrier_func: ERROR thread %d could not get semaphore value\n", id); } + FFLUSH(); #ifndef CONFIG_DISABLE_SIGNALS usleep(HALF_SECOND); #endif printf("barrier_func: Thread %d done\n", id); + FFLUSH(); return NULL; } @@ -158,12 +161,15 @@ void barrier_test(void) { printf("barrier_test: Error in thread %d create, status=%d\n", i, status); + printf("barrier_test: Test aborted with waiting threads\n"); + goto abort_test; } else { printf("barrier_test: Thread %d created\n", i); } } + FFLUSH(); /* Wait for all thread instances to complete */ @@ -184,6 +190,7 @@ void barrier_test(void) /* Destroy the barrier */ +abort_test: status = pthread_barrier_destroy(&barrier); if (status != OK) { @@ -197,4 +204,5 @@ void barrier_test(void) printf("barrier_test: pthread_barrierattr_destroy failed, status=%d\n", status); } + FFLUSH(); } diff --git a/apps/examples/ostest/ostest.h b/apps/examples/ostest/ostest.h index 1cd705898..99290828e 100644 --- a/apps/examples/ostest/ostest.h +++ b/apps/examples/ostest/ostest.h @@ -1,7 +1,7 @@ /**************************************************************************** * examples/ostest/ostest.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -79,6 +79,18 @@ # define dump_nfreeholders(s) #endif +/* If CONFIG_STDIO_LINEBUFFER is defined, the STDIO buffer will be flushed + * on each new line. Otherwise, STDIO needs to be explicitly flushed to + * see the output in context. + */ + +#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && \ + CONFIG_STDIO_BUFFER_SIZE > 0 && !defined(CONFIG_STDIO_LINEBUFFER) +# define FFLUSH() fflush(stdout) +#else +# define FFLUSH() +#endif + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/ostest/posixtimer.c b/apps/examples/ostest/posixtimer.c index 457b4c1a2..3560c712b 100644 --- a/apps/examples/ostest/posixtimer.c +++ b/apps/examples/ostest/posixtimer.c @@ -1,7 +1,7 @@ /*********************************************************************** * examples/ostest/posixtimer.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -56,12 +56,6 @@ #define MY_TIMER_SIGNAL 17 #define SIGVALUE_INT 42 -#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 -# define FFLUSH() fflush(stdout) -#else -# define FFLUSH() -#endif - /************************************************************************** * Private Data **************************************************************************/ diff --git a/apps/examples/ostest/prioinherit.c b/apps/examples/ostest/prioinherit.c index 5d59c1297..993c9e14a 100644 --- a/apps/examples/ostest/prioinherit.c +++ b/apps/examples/ostest/prioinherit.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/ostest/prioinherit.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -139,7 +139,7 @@ static void *highpri_thread(void *parameter) g_highstate[threadno-1] = RUNNING; printf("highpri_thread-%d: Started\n", threadno); - fflush(stdout); + FFLUSH(); sleep(1); printf("highpri_thread-%d: Calling sem_wait()\n", threadno); @@ -162,7 +162,7 @@ static void *highpri_thread(void *parameter) sem_post(&g_sem); printf("highpri_thread-%d: Okay... I'm done!\n", threadno); - fflush(stdout); + FFLUSH(); return NULL; } @@ -202,7 +202,7 @@ static void *medpri_thread(void *parameter) { printf("medpri_thread: Started ... I won't let go of the CPU!\n"); g_middlestate = RUNNING; - fflush(stdout); + FFLUSH(); /* The following loop will completely block lowpri_thread from running. * UNLESS priority inheritance is working. In that case, its priority @@ -215,7 +215,7 @@ static void *medpri_thread(void *parameter) } printf("medpri_thread: Okay... I'm done!\n"); - fflush(stdout); + FFLUSH(); g_middlestate = DONE; return NULL; } @@ -273,7 +273,7 @@ static void *lowpri_thread(void *parameter) } printf(" I still have a count on the semaphore\n"); sem_enumholders(&g_sem); - fflush(stdout); + FFLUSH(); sleep(1); } @@ -365,7 +365,7 @@ static void *lowpri_thread(void *parameter) sem_enumholders(&g_sem); printf("lowpri_thread-%d: Okay... I'm done!\n", threadno); - fflush(stdout); + FFLUSH(); g_lowstate[threadno-1] = DONE; return retval; } @@ -466,7 +466,7 @@ void priority_inheritance(void) { printf("priority_inheritance: Set medpri_thread priority to %d\n", sparam.sched_priority); } - fflush(stdout); + FFLUSH(); status = pthread_create(&medpri, &attr, medpri_thread, NULL); if (status != 0) @@ -501,7 +501,7 @@ void priority_inheritance(void) printf("priority_inheritance: Set highpri_thread-%d priority to %d\n", threadno, sparam.sched_priority); } - fflush(stdout); + FFLUSH(); status = pthread_create(&highpri[i], &attr, highpri_thread, (void*)threadno); if (status != 0) @@ -510,25 +510,25 @@ void priority_inheritance(void) } } dump_nfreeholders("priority_inheritance:"); - fflush(stdout); + FFLUSH(); /* Wait for all thread instances to complete */ for (i = 0; i < NHIGHPRI_THREADS; i++) { printf("priority_inheritance: Waiting for highpri_thread-%d to complete\n", i+1); - fflush(stdout); + FFLUSH(); (void)pthread_join(highpri[i], &result); dump_nfreeholders("priority_inheritance:"); } printf("priority_inheritance: Waiting for medpri_thread to complete\n"); - fflush(stdout); + FFLUSH(); (void)pthread_join(medpri, &result); dump_nfreeholders("priority_inheritance:"); for (i = 0; i < NLOWPRI_THREADS; i++) { printf("priority_inheritance: Waiting for lowpri_thread-%d to complete\n", i+1); - fflush(stdout); + FFLUSH(); (void)pthread_join(lowpri[i], &result); dump_nfreeholders("priority_inheritance:"); } @@ -536,6 +536,6 @@ void priority_inheritance(void) printf("priority_inheritance: Finished\n"); sem_destroy(&g_sem); dump_nfreeholders("priority_inheritance:"); - fflush(stdout); + FFLUSH(); #endif /* CONFIG_PRIORITY_INHERITANCE && !CONFIG_DISABLE_SIGNALS && !CONFIG_DISABLE_PTHREAD */ } diff --git a/apps/examples/ostest/sighand.c b/apps/examples/ostest/sighand.c index 66f98cb58..681531639 100644 --- a/apps/examples/ostest/sighand.c +++ b/apps/examples/ostest/sighand.c @@ -152,10 +152,7 @@ static int waiter_main(int argc, char *argv[]) /* Take the semaphore */ printf("waiter_main: Waiting on semaphore\n" ); - -#if CONFIG_NFILE_STREAMS > 0 - fflush(stdout); -#endif + FFLUSH(); status = sem_wait(&sem); if (status != 0) @@ -181,10 +178,7 @@ static int waiter_main(int argc, char *argv[]) status = sigaction(WAKEUP_SIGNAL, &act, &oact); printf("waiter_main: done\n" ); - -#if CONFIG_NFILE_STREAMS > 0 - fflush(stdout); -#endif + FFLUSH(); threadexited = true; return 0; @@ -231,9 +225,7 @@ void sighand_test(void) /* Wait a bit */ -#if CONFIG_NFILE_STREAMS > 0 - fflush(stdout); -#endif + FFLUSH(); sleep(2); /* Then signal the waiter thread. */ @@ -255,9 +247,7 @@ void sighand_test(void) /* Wait a bit */ -#if CONFIG_NFILE_STREAMS > 0 - fflush(stdout); -#endif + FFLUSH(); sleep(2); /* Then check the result */ @@ -273,7 +263,5 @@ void sighand_test(void) } printf("sighand_test: done\n" ); -#if CONFIG_NFILE_STREAMS > 0 - fflush(stdout); -#endif + FFLUSH(); } diff --git a/apps/examples/ostest/timedmqueue.c b/apps/examples/ostest/timedmqueue.c index 84b8913b2..807d8537b 100644 --- a/apps/examples/ostest/timedmqueue.c +++ b/apps/examples/ostest/timedmqueue.c @@ -69,12 +69,6 @@ #define TEST_SEND_NMSGS (10) #define TEST_RECEIVE_NMSGS (10) -#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 -# define FFLUSH() fflush(stdout) -#else -# define FFLUSH() -#endif - /************************************************************************** * Private Types **************************************************************************/ diff --git a/apps/examples/ostest/timedwait.c b/apps/examples/ostest/timedwait.c index 24edb463b..fc381ddda 100644 --- a/apps/examples/ostest/timedwait.c +++ b/apps/examples/ostest/timedwait.c @@ -49,12 +49,6 @@ * Private Definitions **************************************************************************/ -#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 -# define FFLUSH() fflush(stdout) -#else -# define FFLUSH() -#endif - /************************************************************************** * Private Data **************************************************************************/ |