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
This commit is contained in:
parent
484b5222c3
commit
d4f3d51210
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
****************************************************************************/
|
||||
|
@ -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
|
||||
**************************************************************************/
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
**************************************************************************/
|
||||
|
@ -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
|
||||
**************************************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user