Minor changes to make OS test more robust in the presence of many memory allocation failures

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5672 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-02-26 00:56:59 +00:00
parent 149f975109
commit 869dc0cd9b
3 changed files with 18 additions and 26 deletions

View File

@ -272,7 +272,7 @@ CONFIG_SIG_SIGCONDTIMEDOUT=16
# #
# Sizes of configurable things (0 disables) # Sizes of configurable things (0 disables)
# #
CONFIG_MAX_TASKS=16 CONFIG_MAX_TASKS=8
CONFIG_MAX_TASK_ARGS=4 CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4 CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_DESCRIPTORS=8
@ -288,9 +288,9 @@ CONFIG_PREALLOC_TIMERS=4
# Stack and heap information # Stack and heap information
# #
CONFIG_IDLETHREAD_STACKSIZE=1024 CONFIG_IDLETHREAD_STACKSIZE=1024
CONFIG_USERMAIN_STACKSIZE=2048 CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_PTHREAD_STACK_MIN=256 CONFIG_PTHREAD_STACK_MIN=256
CONFIG_PTHREAD_STACK_DEFAULT=2048 CONFIG_PTHREAD_STACK_DEFAULT=1536
# #
# Device Drivers # Device Drivers
@ -397,7 +397,7 @@ CONFIG_SYMTAB_ORDEREDBYNAME=y
# #
# Standard C Library Options # Standard C Library Options
# #
CONFIG_STDIO_BUFFER_SIZE=64 CONFIG_STDIO_BUFFER_SIZE=0
CONFIG_STDIO_LINEBUFFER=y CONFIG_STDIO_LINEBUFFER=y
CONFIG_NUNGET_CHARS=2 CONFIG_NUNGET_CHARS=2
# CONFIG_LIBM is not set # CONFIG_LIBM is not set
@ -409,7 +409,7 @@ CONFIG_NUNGET_CHARS=2
CONFIG_EOL_IS_EITHER_CRLF=y CONFIG_EOL_IS_EITHER_CRLF=y
# CONFIG_LIBC_EXECFUNCS is not set # CONFIG_LIBC_EXECFUNCS is not set
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
# CONFIG_LIBC_STRERROR is not set # CONFIG_LIBC_STRERROR is not set
# CONFIG_LIBC_PERROR_STDOUT is not set # CONFIG_LIBC_PERROR_STDOUT is not set
CONFIG_ARCH_LOWPUTC=y CONFIG_ARCH_LOWPUTC=y
@ -469,7 +469,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
CONFIG_EXAMPLES_OSTEST=y CONFIG_EXAMPLES_OSTEST=y
# CONFIG_EXAMPLES_OSTEST_BUILTIN is not set # CONFIG_EXAMPLES_OSTEST_BUILTIN is not set
CONFIG_EXAMPLES_OSTEST_LOOPS=1 CONFIG_EXAMPLES_OSTEST_LOOPS=1
CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 CONFIG_EXAMPLES_OSTEST_STACKSIZE=1536
CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
CONFIG_EXAMPLES_OSTEST_RR_RANGE=10000 CONFIG_EXAMPLES_OSTEST_RR_RANGE=10000
CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 CONFIG_EXAMPLES_OSTEST_RR_RUNS=10
@ -493,10 +493,6 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10
# CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_USBTERM is not set
# CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WATCHDOG is not set
#
# Interpreters
#
# #
# Interpreters # Interpreters
# #
@ -524,10 +520,6 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10
# CONFIG_NETUTILS_UIPLIB is not set # CONFIG_NETUTILS_UIPLIB is not set
# CONFIG_NETUTILS_WEBCLIENT is not set # CONFIG_NETUTILS_WEBCLIENT is not set
#
# ModBus
#
# #
# FreeModbus # FreeModbus
# #

View File

@ -116,6 +116,7 @@ static inline int group_addmember(FAR struct task_group_s *group, pid_t pid)
if (!newmembers) if (!newmembers)
{ {
sdbg("ERROR: Failed to reallocate tg_members\n");
return -ENOMEM; return -ENOMEM;
} }

View File

@ -245,7 +245,7 @@ static inline void group_release(FAR struct task_group_s *group)
*****************************************************************************/ *****************************************************************************/
#ifdef HAVE_GROUP_MEMBERS #ifdef HAVE_GROUP_MEMBERS
static inline int group_removemember(FAR struct task_group_s *group, pid_t pid) static inline void group_removemember(FAR struct task_group_s *group, pid_t pid)
{ {
irqstate_t flags; irqstate_t flags;
int i; int i;
@ -269,12 +269,8 @@ static inline int group_removemember(FAR struct task_group_s *group, pid_t pid)
group->tg_members[i] = group->tg_members[group->tg_nmembers - 1]; group->tg_members[i] = group->tg_members[group->tg_nmembers - 1];
group->tg_nmembers--; group->tg_nmembers--;
irqrestore(flags); irqrestore(flags);
return group->tg_nmembers;
} }
} }
return -ENOENT;
} }
#endif /* HAVE_GROUP_MEMBERS */ #endif /* HAVE_GROUP_MEMBERS */
@ -310,21 +306,24 @@ void group_leave(FAR struct tcb_s *tcb)
DEBUGASSERT(tcb); DEBUGASSERT(tcb);
/* Make sure that we have a group */ /* Make sure that we have a group. */
group = tcb->group; group = tcb->group;
if (group) if (group)
{ {
/* Remove the member from group */ /* Remove the member from group. This function may be called
* during certain error handling before the PID has been
* added to the group. In this case tcb->pid will be uninitialized
* group_removemember() will fail.
*/
int ret = group_removemember(group, tcb->pid); group_removemember(group, tcb->pid);
DEBUGASSERT(ret >= 0);
/* Is the group now empty? */ /* Have all of the members left the group? */
if (ret == 0) if (group->tg_nmembers == 0)
{ {
/* Release all of the resource held by the task group */ /* Yes.. Release all of the resource held by the task group */
group_release(group); group_release(group);
} }