aboutsummaryrefslogtreecommitdiffstats
path: root/demos/various/RT-Win32-Simulator/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'demos/various/RT-Win32-Simulator/main.c')
-rw-r--r--demos/various/RT-Win32-Simulator/main.c70
1 files changed, 10 insertions, 60 deletions
diff --git a/demos/various/RT-Win32-Simulator/main.c b/demos/various/RT-Win32-Simulator/main.c
index 17b2346c6..d4a3da302 100644
--- a/demos/various/RT-Win32-Simulator/main.c
+++ b/demos/various/RT-Win32-Simulator/main.c
@@ -30,61 +30,7 @@ static thread_t *cdtp;
static thread_t *shelltp1;
static thread_t *shelltp2;
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.esp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state], (uint32_t)tp->p_time);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
-
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -128,7 +74,8 @@ static void termination_handler(eventid_t id) {
chThdSleepMilliseconds(10);
cputs("Init: shell on SD1 terminated");
chSysLock();
- chOQResetI(&SD1.oqueue);
+ oqResetI(&SD1.oqueue);
+ chSchRescheduleS();
chSysUnlock();
}
if (shelltp2 && chThdTerminatedX(shelltp2)) {
@@ -137,7 +84,8 @@ static void termination_handler(eventid_t id) {
chThdSleepMilliseconds(10);
cputs("Init: shell on SD2 terminated");
chSysLock();
- chOQResetI(&SD2.oqueue);
+ oqResetI(&SD2.oqueue);
+ chSchRescheduleS();
chSysUnlock();
}
}
@@ -161,7 +109,8 @@ static void sd1_handler(eventid_t id) {
if (flags & CHN_DISCONNECTED) {
cputs("Init: disconnection on SD1");
chSysLock();
- chIQResetI(&SD1.iqueue);
+ iqResetI(&SD1.iqueue);
+ chSchRescheduleS();
chSysUnlock();
}
}
@@ -183,7 +132,8 @@ static void sd2_handler(eventid_t id) {
if (flags & CHN_DISCONNECTED) {
cputs("Init: disconnection on SD2");
chSysLock();
- chIQResetI(&SD2.iqueue);
+ iqResetI(&SD2.iqueue);
+ chSchRescheduleS();
chSysUnlock();
}
}
@@ -225,8 +175,8 @@ int main(void) {
/*
* Console thread started.
*/
- cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, NORMALPRIO + 1,
- console_thread, NULL);
+ cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, "console",
+ NORMALPRIO + 1, console_thread, NULL);
/*
* Initializing connection/disconnection events.