mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-06 14:43:35 +08:00
Delete rtems_bsd_thread_chain
Rely on RTEMS object registration for threads.
This commit is contained in:
parent
ccbc70df3e
commit
6604dc893e
@ -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 */
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
const struct thread *td = rtems_bsd_get_thread(thread);
|
||||
|
||||
printf("thread dump:\n");
|
||||
if (td != NULL) {
|
||||
char buf[5];
|
||||
const char *name = td->td_name;
|
||||
|
||||
while (!rtems_chain_is_tail(chain, node)) {
|
||||
const struct thread *td = (const struct thread *) node;
|
||||
if (name == NULL || name[0] == '\0') {
|
||||
rtems_object_get_name(thread->Object.id, sizeof(buf), &buf[0]);
|
||||
name = &buf[0];
|
||||
}
|
||||
|
||||
printf("\t%s: 0x%08x\n", td->td_name, rtems_bsd_get_task_id(td));
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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, \
|
||||
|
Loading…
x
Reference in New Issue
Block a user