summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/Kconfig2
-rw-r--r--apps/examples/ostest/sem.c58
-rw-r--r--apps/examples/ostest/waitpid.c31
-rw-r--r--apps/interpreters/Kconfig2
-rw-r--r--apps/modbus/Kconfig2
-rw-r--r--nuttx/configs/nutiny-nuc120/ostest/defconfig20
-rw-r--r--nuttx/sched/group_join.c1
-rw-r--r--nuttx/sched/group_leave.c23
8 files changed, 87 insertions, 52 deletions
diff --git a/apps/Kconfig b/apps/Kconfig
index 68c36f5a5..83626eb1b 100644
--- a/apps/Kconfig
+++ b/apps/Kconfig
@@ -19,7 +19,7 @@ menu "Network Utilities"
source "$APPSDIR/netutils/Kconfig"
endmenu
-menu "ModBus"
+menu "FreeModBus"
source "$APPSDIR/modbus/Kconfig"
endmenu
diff --git a/apps/examples/ostest/sem.c b/apps/examples/ostest/sem.c
index 48be57a85..6f979dcc7 100644
--- a/apps/examples/ostest/sem.c
+++ b/apps/examples/ostest/sem.c
@@ -140,9 +140,9 @@ static void *poster_func(void *parameter)
void sem_test(void)
{
- pthread_t waiter_thread1;
- pthread_t waiter_thread2;
- pthread_t poster_thread;
+ pthread_t waiter_thread1 = (pthread_t)0;
+ pthread_t waiter_thread2 = (pthread_t)0;
+ pthread_t poster_thread = (pthread_t)0;
#ifdef SDCC
pthread_addr_t result;
#endif
@@ -173,7 +173,7 @@ void sem_test(void)
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status);
+ printf("sem_test: ERROR: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
@@ -183,21 +183,21 @@ void sem_test(void)
status = pthread_create(&waiter_thread1, &attr, waiter_func, (pthread_addr_t)1);
if (status != 0)
{
- printf("sem_test: Error in thread 1 creation, status=%d\n", status);
+ printf("sem_test: ERROR: Thread 1 creation failed: %d\n", status);
}
printf("sem_test: Starting waiter thread 2\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("sem_test: pthread_attr_init failed, status=%d\n", status);
+ printf("sem_test: ERROR: pthread_attr_init failed, status=%d\n", status);
}
sparam.sched_priority = prio_mid;
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status);
+ printf("sem_test: ERROR: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
@@ -207,14 +207,14 @@ void sem_test(void)
status = pthread_create(&waiter_thread2, &attr, waiter_func, (pthread_addr_t)2);
if (status != 0)
{
- printf("sem_test: Error in thread 2 creation, status=%d\n", status);
+ printf("sem_test: ERROR: Thread 2 creation failed: %d\n", status);
}
printf("sem_test: Starting poster thread 3\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("sem_test: pthread_attr_init failed, status=%d\n", status);
+ printf("sem_test: ERROR: pthread_attr_init failed, status=%d\n", status);
}
sparam.sched_priority = (prio_min + prio_mid) / 2;
@@ -231,16 +231,42 @@ void sem_test(void)
status = pthread_create(&poster_thread, &attr, poster_func, (pthread_addr_t)3);
if (status != 0)
{
- printf("sem_test: Error in thread 3 creation, status=%d\n", status);
+ printf("sem_test: ERROR: Thread 3 creation failed: %d\n", status);
+ printf(" Canceling waiter threads\n");
+
+ pthread_cancel(waiter_thread1);
+ pthread_cancel(waiter_thread2);
}
#ifdef SDCC
- pthread_join(waiter_thread1, &result);
- pthread_join(waiter_thread2, &result);
- pthread_join(poster_thread, &result);
+ if (waiter_thread1 != (pthread_t)0)
+ {
+ pthread_join(waiter_thread1, &result);
+ }
+
+ if (waiter_thread2 != (pthread_t)0)
+ {
+ pthread_join(waiter_thread2, &result);
+ }
+
+ if (poster_thread != (pthread_t)0)
+ {
+ pthread_join(poster_thread, &result);
+ }
#else
- pthread_join(waiter_thread1, NULL);
- pthread_join(waiter_thread2, NULL);
- pthread_join(poster_thread, NULL);
+ if (waiter_thread1 != (pthread_t)0)
+ {
+ pthread_join(waiter_thread1, NULL);
+ }
+
+ if (waiter_thread2 != (pthread_t)0)
+ {
+ pthread_join(waiter_thread2, NULL);
+ }
+
+ if (poster_thread != (pthread_t)0)
+ {
+ pthread_join(poster_thread, NULL);
+ }
#endif
}
diff --git a/apps/examples/ostest/waitpid.c b/apps/examples/ostest/waitpid.c
index 67cd81fdc..0649748a2 100644
--- a/apps/examples/ostest/waitpid.c
+++ b/apps/examples/ostest/waitpid.c
@@ -87,7 +87,7 @@ static void waitpid_start_children(void)
ret = TASK_CREATE("waitpid", PRIORITY, STACKSIZE, waitpid_main, NULL);
if (ret < 0)
{
- printf("waitpid_start_child: ERROR Failed to start user_main\n");
+ printf("waitpid_start_child: ERROR Failed to start waitpid_main\n");
}
else
{
@@ -100,8 +100,29 @@ static void waitpid_start_children(void)
static void waitpid_last(void)
{
+ pid_t pid = -1;
int stat_loc;
int ret;
+ int i;
+
+ /* Find the last child thread that was started successfully */
+
+ for (i = NCHILDREN-1; i > 0; i--)
+ {
+ if (g_waitpids[i] >= 0)
+ {
+ pid = i;
+ break;
+ }
+ }
+
+ /* Is there any thread to wait for? */
+
+ if (pid < 0)
+ {
+ printf("waitpid_last: ERROR: Nothing to wait for\n");
+ return;
+ }
printf("waitpid_last: Waiting for PID=%d with waitpid()\n",
g_waitpids[NCHILDREN-1]);
@@ -196,7 +217,7 @@ int waitpid_test(void)
g_waitpids[0], stat_loc);
}
- /* Wait a big to make sure that the other threads complete */
+ /* Wait a bit to make sure that the other threads complete */
waitpid_last();
sleep(1);
@@ -246,7 +267,7 @@ int waitpid_test(void)
info.si_pid, info.si_status);
}
- /* Wait a big to make sure that the other threads complete */
+ /* Wait a bit to make sure that the other threads complete */
waitpid_last();
sleep(1);
@@ -289,7 +310,7 @@ int waitpid_test(void)
info.si_pid, info.si_status);
}
- /* Wait a big to make sure that the other threads complete */
+ /* Wait a bit to make sure that the other threads complete */
waitpid_last();
sleep(1);
@@ -332,7 +353,7 @@ int waitpid_test(void)
ret, stat_loc);
}
- /* Wait a big to make sure that the other threads complete */
+ /* Wait a bit to make sure that the other threads complete */
waitpid_last();
sleep(1);
diff --git a/apps/interpreters/Kconfig b/apps/interpreters/Kconfig
index 6e7d1ac4f..637dd13c5 100644
--- a/apps/interpreters/Kconfig
+++ b/apps/interpreters/Kconfig
@@ -3,8 +3,6 @@
# see misc/tools/kconfig-language.txt.
#
-comment "Interpreters"
-
source "$APPSDIR/interpreters/ficl/Kconfig"
config INTERPRETERS_PCODE
diff --git a/apps/modbus/Kconfig b/apps/modbus/Kconfig
index da95abf6a..a4194e475 100644
--- a/apps/modbus/Kconfig
+++ b/apps/modbus/Kconfig
@@ -3,8 +3,6 @@
# see misc/tools/kconfig-language.txt.
#
-comment "FreeModbus"
-
config MODBUS
bool "Modbus support via FreeModBus"
default n
diff --git a/nuttx/configs/nutiny-nuc120/ostest/defconfig b/nuttx/configs/nutiny-nuc120/ostest/defconfig
index c7280484c..3256fb1eb 100644
--- a/nuttx/configs/nutiny-nuc120/ostest/defconfig
+++ b/nuttx/configs/nutiny-nuc120/ostest/defconfig
@@ -272,7 +272,7 @@ CONFIG_SIG_SIGCONDTIMEDOUT=16
#
# Sizes of configurable things (0 disables)
#
-CONFIG_MAX_TASKS=16
+CONFIG_MAX_TASKS=8
CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=8
@@ -288,9 +288,9 @@ CONFIG_PREALLOC_TIMERS=4
# Stack and heap information
#
CONFIG_IDLETHREAD_STACKSIZE=1024
-CONFIG_USERMAIN_STACKSIZE=2048
+CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_PTHREAD_STACK_MIN=256
-CONFIG_PTHREAD_STACK_DEFAULT=2048
+CONFIG_PTHREAD_STACK_DEFAULT=1536
#
# Device Drivers
@@ -397,7 +397,7 @@ CONFIG_SYMTAB_ORDEREDBYNAME=y
#
# Standard C Library Options
#
-CONFIG_STDIO_BUFFER_SIZE=64
+CONFIG_STDIO_BUFFER_SIZE=0
CONFIG_STDIO_LINEBUFFER=y
CONFIG_NUNGET_CHARS=2
# CONFIG_LIBM is not set
@@ -409,7 +409,7 @@ CONFIG_NUNGET_CHARS=2
CONFIG_EOL_IS_EITHER_CRLF=y
# CONFIG_LIBC_EXECFUNCS is not set
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_PERROR_STDOUT is not set
CONFIG_ARCH_LOWPUTC=y
@@ -469,7 +469,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
CONFIG_EXAMPLES_OSTEST=y
# CONFIG_EXAMPLES_OSTEST_BUILTIN is not set
CONFIG_EXAMPLES_OSTEST_LOOPS=1
-CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048
+CONFIG_EXAMPLES_OSTEST_STACKSIZE=1536
CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
CONFIG_EXAMPLES_OSTEST_RR_RANGE=10000
CONFIG_EXAMPLES_OSTEST_RR_RUNS=10
@@ -496,10 +496,6 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10
#
# Interpreters
#
-
-#
-# Interpreters
-#
# CONFIG_INTERPRETERS_FICL is not set
# CONFIG_INTERPRETERS_PCODE is not set
@@ -525,10 +521,6 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10
# CONFIG_NETUTILS_WEBCLIENT is not set
#
-# ModBus
-#
-
-#
# FreeModbus
#
# CONFIG_MODBUS is not set
diff --git a/nuttx/sched/group_join.c b/nuttx/sched/group_join.c
index d6ca6d498..e760a62d2 100644
--- a/nuttx/sched/group_join.c
+++ b/nuttx/sched/group_join.c
@@ -116,6 +116,7 @@ static inline int group_addmember(FAR struct task_group_s *group, pid_t pid)
if (!newmembers)
{
+ sdbg("ERROR: Failed to reallocate tg_members\n");
return -ENOMEM;
}
diff --git a/nuttx/sched/group_leave.c b/nuttx/sched/group_leave.c
index 490a66ec0..44c52a56d 100644
--- a/nuttx/sched/group_leave.c
+++ b/nuttx/sched/group_leave.c
@@ -245,7 +245,7 @@ static inline void group_release(FAR struct task_group_s *group)
*****************************************************************************/
#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;
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_nmembers--;
irqrestore(flags);
-
- return group->tg_nmembers;
}
}
-
- return -ENOENT;
}
#endif /* HAVE_GROUP_MEMBERS */
@@ -310,21 +306,24 @@ void group_leave(FAR struct tcb_s *tcb)
DEBUGASSERT(tcb);
- /* Make sure that we have a group */
+ /* Make sure that we have a group. */
group = tcb->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);
- DEBUGASSERT(ret >= 0);
+ group_removemember(group, tcb->pid);
- /* 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);
}