[rtems-libbsd commit] Delete rtems_bsd_thread_chain
Sebastian Huber
sebh at rtems.org
Thu Sep 25 08:49:57 UTC 2014
Module: rtems-libbsd
Branch: master
Commit: 6604dc893e784ba55c315eac1e455189dbbd8164
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=6604dc893e784ba55c315eac1e455189dbbd8164
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Sep 25 10:48:14 2014 +0200
Delete rtems_bsd_thread_chain
Rely on RTEMS object registration for threads.
---
freebsd/sys/sys/proc.h | 6 +-
rtemsbsd/include/machine/rtems-bsd-thread.h | 2 -
rtemsbsd/include/rtems/bsd/bsd.h | 2 -
rtemsbsd/include/rtems/netcmds-config.h | 31 +++++---
rtemsbsd/rtems/rtems-bsd-panic.c | 29 +------
rtemsbsd/rtems/rtems-bsd-shell.c | 84 ++++++++++---------
rtemsbsd/rtems/rtems-bsd-thread.c | 14 +---
.../include/rtems/bsd/test/default-network-init.h | 1 +
8 files changed, 70 insertions(+), 99 deletions(-)
diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h
index 84a1b4a..58d7d6c 100644
--- a/freebsd/sys/sys/proc.h
+++ b/freebsd/sys/sys/proc.h
@@ -201,15 +201,11 @@ struct rusage_ext {
* This is what is put to sleep and reactivated.
* Thread context. Processes may have multiple threads.
*/
-#ifdef __rtems__
-#include <rtems/chain.h>
-#endif /* __rtems__ */
struct thread {
#ifdef __rtems__
- rtems_chain_node td_node;
Thread_Control *td_thread;
struct rtems_bsd_program_control *td_prog_ctrl;
- char td_name [16];
+ char td_name[32];
#endif /* __rtems__ */
#ifndef __rtems__
struct mtx *volatile td_lock; /* replaces sched lock */
diff --git a/rtemsbsd/include/machine/rtems-bsd-thread.h b/rtemsbsd/include/machine/rtems-bsd-thread.h
index 81aef32..41e08ef 100644
--- a/rtemsbsd/include/machine/rtems-bsd-thread.h
+++ b/rtemsbsd/include/machine/rtems-bsd-thread.h
@@ -68,8 +68,6 @@ struct sleepqueue {
void *sq_wchan;
};
-extern rtems_chain_control rtems_bsd_thread_chain;
-
struct thread *
rtems_bsd_get_thread(const Thread_Control *thread);
diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h
index 7156545..af03b44 100644
--- a/rtemsbsd/include/rtems/bsd/bsd.h
+++ b/rtemsbsd/include/rtems/bsd/bsd.h
@@ -70,8 +70,6 @@ extern const size_t rtems_bsd_nexus_device_count;
rtems_status_code rtems_bsd_initialize(void);
-void rtems_bsd_shell_initialize(void);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/rtemsbsd/include/rtems/netcmds-config.h b/rtemsbsd/include/rtems/netcmds-config.h
index 199afbe..d9ccd69 100644
--- a/rtemsbsd/include/rtems/netcmds-config.h
+++ b/rtemsbsd/include/rtems/netcmds-config.h
@@ -18,17 +18,24 @@
#include <rtems/shell.h>
-/*
- * Externs for all command definition structures
- */
-// #if RTEMS_NETWORKING
- extern rtems_shell_cmd_t rtems_shell_PING_Command;
- extern rtems_shell_cmd_t rtems_shell_PING6_Command;
-
- extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
- extern rtems_shell_cmd_t rtems_shell_ROUTE_Command;
- extern rtems_shell_cmd_t rtems_shell_NETSTAT_Command;
- extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command;
-// #endif
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern rtems_shell_cmd_t rtems_shell_BSD_Command;
+
+extern rtems_shell_cmd_t rtems_shell_PING_Command;
+extern rtems_shell_cmd_t rtems_shell_PING6_Command;
+
+extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
+extern rtems_shell_cmd_t rtems_shell_ROUTE_Command;
+extern rtems_shell_cmd_t rtems_shell_NETSTAT_Command;
+extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command;
+
+extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
#endif
diff --git a/rtemsbsd/rtems/rtems-bsd-panic.c b/rtemsbsd/rtems/rtems-bsd-panic.c
index 9634e19..1fc65f0 100644
--- a/rtemsbsd/rtems/rtems-bsd-panic.c
+++ b/rtemsbsd/rtems/rtems-bsd-panic.c
@@ -43,38 +43,13 @@
#include <rtems/bsd/sys/param.h>
#include <rtems/bsd/sys/types.h>
#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <rtems/bsd/sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-
-static void
-suspend_all_threads(void)
-{
- const rtems_chain_control *chain = &rtems_bsd_thread_chain;
- const rtems_chain_node *node = rtems_chain_immutable_first(chain);
- rtems_id self = rtems_task_self();
-
- while (!rtems_chain_is_tail(chain, node)) {
- const struct thread *td = (const struct thread *) node;
- rtems_id id = rtems_bsd_get_task_id(td);
-
- if (id != self) {
- rtems_task_suspend(id);
- }
-
- node = rtems_chain_immutable_next(node);
- }
-
- rtems_task_suspend(RTEMS_SELF);
-}
void
panic(const char *fmt, ...)
{
va_list ap;
- printf("*** BSD PANIC *** ");
+ printf("\n*** BSD PANIC *** ");
va_start(ap, fmt);
vprintf(fmt, ap);
@@ -82,7 +57,7 @@ panic(const char *fmt, ...)
printf("\n");
- suspend_all_threads();
+ rtems_task_suspend(RTEMS_SELF);
/* FIXME */
rtems_fatal_error_occurred(0xdeadbeef);
diff --git a/rtemsbsd/rtems/rtems-bsd-shell.c b/rtemsbsd/rtems/rtems-bsd-shell.c
index 7ccb170..25daf62 100644
--- a/rtemsbsd/rtems/rtems-bsd-shell.c
+++ b/rtemsbsd/rtems/rtems-bsd-shell.c
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -46,67 +46,71 @@
#include <sys/systm.h>
#include <sys/proc.h>
-#include <rtems/bsd/bsd.h>
-#include <rtems/shell.h>
+#include <inttypes.h>
+
+#include <rtems/netcmds-config.h>
static void
-rtems_bsd_dump_thread(void)
+rtems_bsd_dump_thread(Thread_Control *thread)
{
- const rtems_chain_control *chain = &rtems_bsd_thread_chain;
- const rtems_chain_node *node = rtems_chain_immutable_first(chain);
-
- printf("thread dump:\n");
+ const struct thread *td = rtems_bsd_get_thread(thread);
- while (!rtems_chain_is_tail(chain, node)) {
- const struct thread *td = (const struct thread *) node;
+ if (td != NULL) {
+ char buf[5];
+ const char *name = td->td_name;
- printf("\t%s: 0x%08x\n", td->td_name, rtems_bsd_get_task_id(td));
+ if (name == NULL || name[0] == '\0') {
+ rtems_object_get_name(thread->Object.id, sizeof(buf), &buf[0]);
+ name = &buf[0];
+ }
- node = rtems_chain_immutable_next(node);
+ fprintf(
+ stdout,
+ " 0x%08" PRIx32 " | %8" PRIu32 " | %s\n",
+ thread->Object.id,
+ thread->current_priority,
+ name
+ );
}
}
-static const char rtems_bsd_usage [] =
- "bsd {all|condvar|thread|callout}";
+static void
+rtems_bsd_dump_threads(void)
+{
+ fprintf(
+ stdout,
+ "-------------------------------------------------------------------------------\n"
+ " BSD THREADS\n"
+ "------------+----------+-------------------------------------------------------\n"
+ " ID | PRIORITY | NAME\n"
+ "------------+----------+-------------------------------------------------------\n"
+ );
+
+ rtems_iterate_over_all_threads(rtems_bsd_dump_thread);
+
+ fprintf(
+ stdout,
+ "------------+----------+-------------------------------------------------------\n"
+ );
+}
+
+static const char rtems_bsd_usage[] = "bsd";
#define CMP(s) all || strcasecmp(argv [1], s) == 0
static int
rtems_bsd_info(int argc, char **argv)
{
- bool usage = true;
-
- if (argc == 2) {
- bool all = false;
-
- if (CMP("all")) {
- all = true;
- }
-
- if (CMP("thread")) {
- rtems_bsd_dump_thread();
- usage = false;
- }
- }
-
- if (usage) {
- puts(rtems_bsd_usage);
- }
+ rtems_bsd_dump_threads();
return 0;
}
-static rtems_shell_cmd_t rtems_bsd_info_command = {
+rtems_shell_cmd_t rtems_shell_BSD_Command = {
.name = "bsd",
- .usage = rtems_bsd_usage,
+ .usage = &rtems_bsd_usage[0],
.topic = "bsp",
.command = rtems_bsd_info,
.alias = NULL,
.next = NULL
};
-
-void
-rtems_bsd_shell_initialize(void)
-{
- rtems_shell_add_cmd_struct(&rtems_bsd_info_command);
-}
diff --git a/rtemsbsd/rtems/rtems-bsd-thread.c b/rtemsbsd/rtems/rtems-bsd-thread.c
index d233b5e..bdd9aa5 100644
--- a/rtemsbsd/rtems/rtems-bsd-thread.c
+++ b/rtemsbsd/rtems/rtems-bsd-thread.c
@@ -57,8 +57,6 @@
#include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h>
-RTEMS_CHAIN_DEFINE_EMPTY(rtems_bsd_thread_chain);
-
static size_t rtems_bsd_extension_index;
static CHAIN_DEFINE_EMPTY(rtems_bsd_thread_delay_start_chain);
@@ -162,15 +160,14 @@ rtems_bsd_extension_thread_create(
Thread_Control *created
)
{
- bool ok = true;
+ bool ok;
if (rtems_bsd_is_bsd_thread(created)) {
struct thread *td = rtems_bsd_thread_create(created, 0);
ok = td != NULL;
- if (ok) {
- rtems_chain_append(&rtems_bsd_thread_chain, &td->td_node);
- }
+ } else {
+ ok = true;
}
return ok;
@@ -186,11 +183,6 @@ rtems_bsd_extension_thread_delete(
if (td != NULL) {
seltdfini(td);
-
- if (rtems_bsd_is_bsd_thread(deleted)) {
- rtems_chain_extract(&td->td_node);
- }
-
free(td->td_sleepqueue, M_TEMP);
free(td, M_TEMP);
}
diff --git a/testsuite/include/rtems/bsd/test/default-network-init.h b/testsuite/include/rtems/bsd/test/default-network-init.h
index b53a955..5643308 100644
--- a/testsuite/include/rtems/bsd/test/default-network-init.h
+++ b/testsuite/include/rtems/bsd/test/default-network-init.h
@@ -309,6 +309,7 @@ SYSINIT_NEED_NET_PF_UNIX;
#define CONFIGURE_SHELL_USER_COMMANDS \
&bsp_interrupt_shell_command, \
+ &rtems_shell_BSD_Command, \
&rtems_shell_PING_Command, \
&rtems_shell_ROUTE_Command, \
&rtems_shell_NETSTAT_Command, \
More information about the vc
mailing list