有不少网友希望开发一个linux下的RTT模拟器,即simulator的linux版本,其实这方面的工作很早之前就已经有人探索过了,参见
论坛网友parai的帖子:rtThread-posix http://www.rt-thread.org/phpBB3/viewtopic.php?t=1719
这个只是内核的移植,并且还有一些bug,后来parai的兴趣转向其他方向,所以这个工作就荒废了,不过现在有另外一位网友 wizardxbl准备接手这个工作,感谢wizardxbl的热心参与。
1) FreeRTOS 的linux上的模拟器实现(有源码)
帖子地址: http://www.freertos.org/FreeRTOS-simulator-for-Linux.html
在这篇帖子中,给出了大致的说明,并给出了模拟器源码,注意在帖子的最后页说明了这个模拟器存在的问题,所以需要仔细阅读。
源码包我放在这里,大家可以直接下载:
[attachment=-1]
2)[论文一篇 PDF文件] 一种符合POSIX规范的FreeRTOS模拟器的设计与实现
[attach]0[/attach]
APP module支持
如何开发?
现在RTT的源码已经全面转向github,这个模拟器的开发也可以放在github上进行。放置于github上也有利于其他感兴趣的同学一起参与。(我看到grissiom兄在wizardxbl帖子里提及,所以这里算是引用grissiom的建议 [s:158] )。
下载附件 Posix_GCC_Simulator_6.0.4.zip
下载附件[一种符合POSIX规范的FreeRTOS模拟器的设计与实现.pdf]
下载附件 simlinux.7z
目前我发现的情况是rt_system_scheduler_start()
开始之后
线程切换test1->test2->tidle
然后就一直停在tidle
了
前面是根据线程优先级从高优先级到低优先级进行的。
贴一个我写pthread测试程序,可以实现任意suspend/resume
一个线程。
程序的效果:
主线程中创建多个pthead线程,一开始,所有的线程都被挂起(就像RTT中一样,每个被创建的线程一开始都是被挂起的,rt_scheduler
才会真正将其调度运行)
按下CTRL+C键,可以会启动第一个创建的线程,再次按CTRL+C键就会阻塞这个线程,然后循环。
这个程序其实就是一个最简单的RTT内核的thread_switch过程的模拟。
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <semaphore.h>
#define TRACE printf
//#define TRACE(...)
#define NUM_THREADS 2
typedef struct _thread
{
pthread_t pthread;
void (*task) (void *);
void * para;
void (*exit) (void);
sem_t sem;
} thread_t;
static thread_t thread_table[NUM_THREADS];
#define THREAD_T(thread) ((thread_t *)thread)
#define MSG_SUSPEND SIGUSR1
/* #define MSG_RESUME SIGUSR2 */
static void mainthread_signal_handler(int sig)
{
static int i;
pthread_t tid;
tid = pthread_self();
TRACE("thread <%x>! signal <%d>
", (unsigned int)tid, sig);
i = 1-i;
if (i)
{
/* resume the thread */
sem_post(&thread_table[0].sem);
}
else
{
/* suspend the thread */
pthread_kill(thread_table[0].pthread, MSG_SUSPEND);
}
}
static void thread_switch_handler(int sig)
{
if (sig == MSG_SUSPEND)
{
sem_wait(&thread_table[0].sem);
}
}
static void * thread_run(void * parameter)
{
//rt_thread_t tid;
thread_t * thread;
//tid = rt_thread_self();
thread = THREAD_T(parameter);
TRACE("<%x> stop on sem...
", (unsigned int)thread->pthread);
sem_wait(&thread->sem);
TRACE(" <%x> starts running...
", (unsigned int)thread->pthread);
thread->task(thread->para);
TRACE(" <%x> exit...
", (unsigned int)thread->pthread);
thread->exit();
sem_destroy(&thread->sem);
pthread_exit(NULL);
}
static int thread_create(
thread_t * thread, void *task, void *parameter, void *pexit)
{
int res;
pthread_attr_t attr;
//thread_t * thread = THREAD_T(pt);
thread->task = task;
thread->para = parameter;
thread->exit = pexit;
signal_install(MSG_SUSPEND, thread_switch_handler);
if (sem_init(&thread->sem, 0, 0) != 0)
{
printf("init thread->sem failed, exit
");
exit(EXIT_FAILURE);
}
/* No need to join the threads. */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/* create a posix thread */
res = pthread_create(&thread->pthread, &attr, &thread_run, (void *)thread);
if (res)
{
printf("pthread create faild, <%d>
", res);
exit(EXIT_FAILURE);
}
}
int signal_install(int sig, void (*func)(int))
{
struct sigaction act;
/* set the signal handler */
act.sa_handler = func ;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(sig, &act, 0);
}
static void *PrintHello(void *para)
{
pthread_t tid;
tid = pthread_self();
for(;;)
{
printf("thread <%x>! Hello, world!
", (unsigned int)tid);
sleep(1);
//delay(1);
}
}
static void *threadexit()
{
pthread_t tid;
tid = pthread_self();
printf("thread <%x>! I'm leaving.
", (unsigned int)tid);
}
int main (int argc, char *argv[])
{
int t;
pthread_t tid;
/* install signal handler of main thread */
signal_install(SIGINT, mainthread_signal_handler);
/* just output the main thread's id */
tid = pthread_self();
printf("main thread <%x>!
", (unsigned int)tid);
for(t=0; t<NUM_THREADS; t++)
{
thread_create(&thread_table[t], &PrintHello, NULL, &threadexit);
TRACE("main: thread %x created
", (unsigned int)thread_table[t].pthread);
}
for(;;)
{
sleep(10);
}
TRACE("main exit...
");
return 0;
}
编译:
prife@smart:~/git/pthreads$ cat cp.sh
#!/bin/bash
gcc -D_REENTRANT threadv1.c -o threadv1 -lpthread
运行:
prife@smart:~/git/pthreads$ ./threadv1
main thread <b75426c0>!
main: thread b7541b40 created
<b7541b40> stop on sem...
main: thread b6d40b40 created
<b6d40b40> stop on sem...
^Cthread <b75426c0>! signal <2>
<b7541b40> starts running...
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
^Cthread <b75426c0>! signal <2>
^Cthread <b75426c0>! signal <2>
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
^Cthread <b75426c0>! signal <2>
^Cthread <b75426c0>! signal <2>
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
^Cthread <b75426c0>! signal <2>
^Cthread <b75426c0>! signal <2>
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
thread <b7541b40>! Hello, world!
^Cthread <b75426c0>! signal <2>
^退出 (核心已转储)
参考资料:
前排。。学习。
与RTT内核相关的函数总共有6个
rt_hw_stack_init()
rt_hw_interrupt_disable()
rt_hw_interrupt_enable()
rt_hw_context_switch_to()
rt_hw_context_switch()
rt_hw_context_switch_interrupt()
这里面分为4类函数
1 系统启动阶段
初始化阶段,每当建立一个rtt线程,就会调用rt_hw_stack_init()函数一次
2 系统开始调度阶段
调用rt_hw_context_switch_to()函数一次,以后不再调用,这个函数完成底部的线程第一次切换
3 调度器工作阶段rt_hw_context_switch()
rt_hw_context_switch_interrupt()
这两个函数调用,并且前期rt_hw_context_switch()
函数被调用,后期rt_hw_context_switch_interrupt()
函数被调用
4 其他rt_hw_interrupt_disable()
rt_hw_interrupt_enable()
这两个函数的具体功能我还说不好
rt_hw_stack_init()
rt_hw_context_switch_to()
以下两个函数效果一样。在支持硬件终端嵌套时,如果存在中断嵌套,就执行 switch_interrupt..模拟器上不会出现这种情况,所以这两个函数实现可以一致。
rt_hw_context_switch()
rt_hw_context_switch_interrupt()
这两个函数是用来关中断,参考simulator for win32的设计,中断模拟执行是在主线程for循环代码。在windows版本中,使用wait multi object 实现,在linux上可以使用 pthread_mutex + phtread_cond(即互斥锁和条件变量),不过需要注意,pthread_mutex_init默认创建出来的互斥锁是NORMAL型,不支持递归。因为rt_hw_interrupt_disable在rtt中存在嵌套调用的情况,如果mutex不支持递归,则会导致deadlock)。因此需要设置mutex的为递归型mutex.
rt_hw_interrupt_disable()
rt_hw_interrupt_enable()
今天调了一天simulator for linux(非parai的内核代码,而是simulator win32的linux移植版本,参见附件)的内核移植代码。需要多运行几次,大部分时候会都爆段错误,不过偶尔可以正常运行实习线程切换及推退出后调用rt_thread_exit切换其他线程。原因就在于这种实现方式要求主进程(mainthread_schedulor所在的线程)的优先级比普通rtt线程高。但是在linux中,普通权限模式下创建的多线程程序的调度算法只能选择SCHED_OTHER模式,这种模式,多个线程的优先级相同。这就是导致段错误的元凶。
所以现在就有两个显然的思路:
[attach]1707[/attach]
[attach]1708[/attach]
感觉上,还是不要依赖通用操作系统的优先级吧,这东西应该不靠谱……
请教下,POSIX thread 里,signal 是 per thread 的么?每个 thread 有自己的信号处理函数?
感觉上,还是不要依赖通用操作系统的优先级吧,这东西应该不靠谱……
请教下,POSIX thread 里,signal 是 per thread 的么?每个 thread 有自己的信号处理函数?
是啊,方法1不靠谱,我这边改了优先级也不行。方法2已经调试成功了。代码已经推送到github上了。
https://github.com/prife/rt-thread/commits/simposix
线程共享信号处理函数的。
[32m
这种符号是在终端里调试方便加的颜色代码
[32min rt_hw_board_init
[0m[32min rt_hw_serial_init
[0m[32mout rt_hw_serial_init
[0m[32min rt_hw_serial_register
[0m[32mout rt_hw_serial_register
[0m[32min rt_serial_init
[0m[32mout rt_serial_init
[0m[32min rt_serial_open
[0m[32mout rt_serial_open
[0m[32mout rt_hw_board_init
[0m-------------rt_show_version();38--------------
| /
- RT - Thread Operating System
/ | 1.1.0 build Jan 10 2013
2006 - 2012 Copyright by rt-thread team
-------------rt_system_tick_init()45--------------
-------------rt_system_object_init();51--------------
-------------rt_system_timer_init();57--------------
-------------rt_system_heap_init();63--------------
-------------rt_system_scheduler_init();71--------------
-------------rt_device_init_all();77--------------
-------------rt_application_init();84--------------
[32min rt_thread_create
[0m[33m------------------
|-name |init
|-entry |0x401995 (function address)
|-parameter |(null)
|-stack_size|0x800
|-priority |10
|-tick |20
------------------
[0m[33m------------------
|-thread |0x629278(rt_object_allocate->thread)
|-sizeof(thread) |0x8
|-sizeof(rt_thread) |0xf0
------------------
[0m[33m------------------
|-stack_start |0x629380(rt_malloc(stack_size)->stack_start)
------------------
[0m-->in _rt_thread_init [init]
[33m------------------
|-thread |0x629278
|-name |init
|-entry |0x401995
|-parameter |(null)
|-stack_start |0x629380
|-stack_size |0x800
|-priority |10
|-tick |20
------------------
[0m[32mthread->stack_addr:0x6292c0 (addr)
[0m[32mthread->stack_addr:0x629380 (data)
[0mwill call rt_hw_stack_init
[32m------------------
|-thread->sp |0x629b2c
------------------
[0m<--out _rt_thread_init [init]
[32min rt_thread_create
[0mwill rt_thread_startup(0x629278)
in rt_thread_startup(0x629278)
[32min rt_thread_resume
[0m[32mout rt_thread_resume
[0m-----finish creat init and startup-----------------------------------------------
[32min rt_thread_create
[0m[33m------------------
|-name |test1
|-entry |0x4019cb (function address)
|-parameter |(null)
|-stack_size|0x800
|-priority |10
|-tick |20
------------------
[0m[33m------------------
|-thread |0x629b98(rt_object_allocate->thread)
|-sizeof(thread) |0x8
|-sizeof(rt_thread) |0xf0
------------------
[0mpid <9868a700> stop on sem...
[33m------------------
|-stack_start |0x629ca0(rt_malloc(stack_size)->stack_start)
------------------
[0m-->in _rt_thread_init [test1]
[33m------------------
|-thread |0x629b98
|-name |test1
|-entry |0x4019cb
|-parameter |(null)
|-stack_start |0x629ca0
|-stack_size |0x800
|-priority |10
|-tick |20
------------------
[0m[32mthread->stack_addr:0x629be0 (addr)
[0m[32mthread->stack_addr:0x629ca0 (data)
[0mwill call rt_hw_stack_init
[32m------------------
|-thread->sp |0x62a44c
------------------
[0m<--out _rt_thread_init [test1]
[32min rt_thread_create
[0mwill rt_thread_startup(0x629b98)
pid <97e89700> stop on sem...
in rt_thread_startup(0x629b98)
[32min rt_thread_resume
[0m[32mout rt_thread_resume
[0m-----finish create test1 and startup-----------------------------------------------
[32min rt_thread_create
[0m[33m------------------
|-name |test2
|-entry |0x401a28 (function address)
|-parameter |(null)
|-stack_size|0x800
|-priority |20
|-tick |20
------------------
[0m[33m------------------
|-thread |0x62a4b8(rt_object_allocate->thread)
|-sizeof(thread) |0x8
|-sizeof(rt_thread) |0xf0
------------------
[0m[33m------------------
|-stack_start |0x62a5c0(rt_malloc(stack_size)->stack_start)
------------------
[0m-->in _rt_thread_init [test2]
[33m------------------
|-thread |0x62a4b8
|-name |test2
|-entry |0x401a28
|-parameter |(null)
|-stack_start |0x62a5c0
|-stack_size |0x800
|-priority |20
|-tick |20
------------------
[0m[32mthread->stack_addr:0x62a500 (addr)
[0m[32mthread->stack_addr:0x62a5c0 (data)
[0mwill call rt_hw_stack_init
[32m------------------
|-thread->sp |0x62ad6c
------------------
[0mpid <97688700> stop on sem...
<--out _rt_thread_init [test2]
[32min rt_thread_create
[0mwill rt_thread_startup(0x62a4b8)
in rt_thread_startup(0x62a4b8)
[32min rt_thread_resume
[0m[32mout rt_thread_resume
[0m------finish craete test2 and startup----------------------------------------------
-------------rt_system_timer_thread_init();90--------------
[32min rt_thread_init[timer]
[0mthread[0x68d5e0]
struct rt_thread[0x8]
[32mout rt_thread_init
[0m-->in _rt_thread_init [timer]
[33m------------------
|-thread |0x68d5e0
|-name |timer
|-entry |0x406566
|-parameter |(null)
|-stack_start |0x68d6d0
|-stack_size |0x200
|-priority |4
|-tick |10
------------------
[0m[32mthread->stack_addr:0x68d628 (addr)
[0m[32mthread->stack_addr:0x68d6d0 (data)
[0mwill call rt_hw_stack_init
[32m------------------
|-thread->sp |0x68d87c
------------------
[0mpid <96e87700> stop on sem...
<--out _rt_thread_init [timer]
in rt_thread_startup(0x68d5e0)
[32min rt_thread_resume
[0m[32mout rt_thread_resume
[0m-------------rt_thread_idle_init();96--------------
[32min rt_thread_init[tidle]
[0mthread[0x68d280]
struct rt_thread[0x8]
[32mout rt_thread_init
[0m-->in _rt_thread_init [tidle]
[33m------------------
|-thread |0x68d280
|-name |tidle
|-entry |0x4022e2
|-parameter |(null)
|-stack_start |0x68d370
|-stack_size |0x100
|-priority |31
|-tick |32
------------------
[0m[32mthread->stack_addr:0x68d2c8 (addr)
[0m[32mthread->stack_addr:0x68d370 (data)
[0mwill call rt_hw_stack_init
[32m------------------
|-thread->sp |0x68d41c
------------------
[0m<--out _rt_thread_init [tidle]
in rt_thread_startup(0x68d280)
[32min rt_thread_resume
[0m[32mout rt_thread_resume
[0mpid <96686700> stop on sem...
-------------rt_system_scheduler_start();102--------------
in rt_system_scheduler_start()
rt_thread_ready_priority_group = 0x80100410
number = 4
highest_ready_priority = 4
[33m------------------
|-name | timer
-------------------
[0mpid <990af700> mainthread
start system tick!
pid <96e87700> tid <timer> starts...
[42;37min rt_thread_timer_entry[0m[32m
[0m[32min rt_thread_suspend
[0m[33mthread suspend: timer
[0m[32mout rt_thread_suspend
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[0]switch from priority#10 thread:timer
[0m[36m[0]switch to priority#10 thread:init
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mfrome_thread->sp:0x68d87c
[0m[36mto_thread->sp:0x629b2c
[0mconswitch: P in pid<96e87700> ,suspend <timer>, resume <(null)>!
pid <9868a700> tid <init> starts...
in rt_init_thread_entry
out rt_init_thread_entry
pid <9868a700> tid <init> exit...
[32min rt_thread_exit
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[0]switch from priority#10 thread:init
[0m[36m[0]switch to priority#10 thread:test1
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mfrome_thread->sp:0x629b2c
[0m[36mto_thread->sp:0x62a44c
[0mconswitch: P in pid<9868a700> ,suspend <init>, resume <(null)>!
pid <97e89700> tid <test1> starts...
in rt_test1_thread_entry
thread-01:0
[32mint rt_thread_sleep
[0m[32min rt_thread_suspend
[0m[33mthread suspend: test1
[0m[32mout rt_thread_suspend
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[0]switch from priority#20 thread:test1
[0m[36m[0]switch to priority#20 thread:test2
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mfrome_thread->sp:0x62a44c
[0m[36mto_thread->sp:0x62ad6c
[0mconswitch: P in pid<97e89700> ,suspend <test1>, resume <(null)>!
pid <97688700> tid <test2> starts...
thread-02:0
[32mint rt_thread_sleep
[0m[32min rt_thread_suspend
[0m[33mthread suspend: test2
[0m[32mout rt_thread_suspend
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[0]switch from priority#31 thread:test2
[0m[36m[0]switch to priority#31 thread:tidle
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mfrome_thread->sp:0x62ad6c
[0m[36mto_thread->sp:0x68d41c
[0mconswitch: P in pid<97688700> ,suspend <test2>, resume <(null)>!
pid <96686700> tid <tidle> starts...
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
[32min rt_thread_timeout
[0m[32m---->[test2] remove frome suspend list insert to ready list
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[1]switch from priority#20 thread:tidle
[0m[36m[1]switch to priority#20 thread:test2
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mswitch in interrupt
[0m[36m<-----out rt_schedule
[0m[32mout rt_thread_timeout
[0m[32min rt_thread_timeout
[0m[32m---->[test1] remove frome suspend list insert to ready list
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[1]switch from priority#10 thread:test2
[0m[36m[1]switch to priority#10 thread:test1
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mswitch in interrupt
[0m[36m<-----out rt_schedule
[0m[32mout rt_thread_timeout
[0mconswitch: S in pid<990af700> ,suspend <test2>, resume <test1>!
signal: SIGSUSPEND suspend <test2>
conswitch: S in pid<990af700> ,suspend <test2>, resume <test1>!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
[36m<-----out rt_schedule
[0m[32mout rt_thread_sleep
[0mthread-01:1
[32mint rt_thread_sleep
[0m[32min rt_thread_suspend
[0m[33mthread suspend: test1
[0m[32mout rt_thread_suspend
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[0]switch from priority#20 thread:test1
[0m[36m[0]switch to priority#20 thread:test2
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mfrome_thread->sp:0x62a44c
[0m[36mto_thread->sp:0x62ad6c
[0mconswitch: P in pid<97e89700> ,suspend <test1>, resume <test2>!
[36m<-----out rt_schedule
[0m[32mout rt_thread_sleep
[0mthread-01:2
[32mint rt_thread_sleep
[0m[32min rt_thread_suspend
[0m[33mthread suspend: test2
[0m[32mout rt_thread_suspend
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[0]switch from priority#31 thread:test2
[0m[36m[0]switch to priority#31 thread:tidle
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mfrome_thread->sp:0x62ad6c
[0m[36mto_thread->sp:0x68d41c
[0mconswitch: P in pid<97e89700> ,suspend <test2>, resume <tidle>!
signal: SIGSUSPEND resume <test2>
signal: SIGSUSPEND suspend <test2>
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
[32min rt_thread_timeout
[0m[32m---->[test2] remove frome suspend list insert to ready list
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[1]switch from priority#20 thread:tidle
[0m[36m[1]switch to priority#20 thread:test2
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mswitch in interrupt
[0m[36m<-----out rt_schedule
[0m[32mout rt_thread_timeout
[0m[32min rt_thread_timeout
[0m[32m---->[test1] remove frome suspend list insert to ready list
[0m[36m----->in rt_schedule
[0m[36mrt_scheduler_lock_nest:0
[0m[36m[1]switch from priority#10 thread:test2
[0m[36m[1]switch to priority#10 thread:test1
[0m[32min _rt_scheduler_stack_check
[0m[32mout _rt_scheduler_stack_check
[0m[36mswitch in interrupt
[0m[36m<-----out rt_schedule
[0m[32mout rt_thread_timeout
[0mconswitch: S in pid<990af700> ,suspend <test2>, resume <test1>!
conswitch: S in pid<990af700> ,suspend <test2>, resume <test1>!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <990af700> signal: SIGALRM leave!
pid <990af700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
@wizard:~/git/rt-thread/rt-thread-prife/bsp/simlinux$ ./rtthread
| /
- RT - Thread Operating System
/ | 1.2.0 build Jan 15 2013
2006 - 2012 Copyright by rt-thread team
pid <fc48c700> stop on sem...
pid <fd630700> mainthread
pid <fb48a700> stop on sem...
start system tick!
pid <fc48c700> tid <init> starts...
pid <fbc8b700> stop on sem...
pid <fac89700> stop on sem...
pid <fc48c700> tid <init> exit...
conswitch: P in pid<fc48c700> ,suspend <init>, resume <(null)>!
pid <fac89700> tid <tshell> starts...
finsh>>conswitch: P in pid<fac89700> ,suspend <tshell>, resume <(null)>!
pid <fbc8b700> tid <test> starts...
hello, world
conswitch: P in pid<fbc8b700> ,suspend <test>, resume <(null)>!
pid <fb48a700> tid <tidle> starts...
pid <fd630700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <fd630700> signal: SIGALRM leave!
pid <fd630700> signal: SIGALRM enter!
isr: systick enter!
conswitch: S in pid<fd630700> ,suspend <tidle>, resume <test>!
signal: SIGSUSPEND suspend <tidle>
hello, world
isr: systick leave!
pid <fd630700> signal: SIGALRM leave!
conswitch: P in pid<fbc8b700> ,suspend <test>, resume <tidle>!
signal: SIGSUSPEND resume <tidle>
pid <fd630700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <fd630700> signal: SIGALRM leave!
pid <fd630700> signal: SIGALRM enter!
isr: systick enter!
conswitch: S in pid<fd630700> ,suspend <tidle>, resume <test>!
isr: systick leave!
pid <fd630700> signal: SIGALRM leave!
signal: SIGSUSPEND suspend <tidle>
hello, world
conswitch: P in pid<fbc8b700> ,suspend <test>, resume <tidle>!
signal: SIGSUSPEND resume <tidle>
conswitch: S in pid<fcc8d700> ,suspend <tidle>, resume <tshell>!
finsh>>signal: SIGSUSPEND suspend <tidle>
conswitch: P in pid<fac89700> ,suspend <tshell>, resume <tidle>!
signal: SIGSUSPEND resume <tidle>
pid <fd630700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <fd630700> signal: SIGALRM leave!
conswitch: S in pid<fcc8d700> ,suspend <tidle>, resume <tshell>!
signal: SIGSUSPEND suspend <tidle>
aconswitch: P in pid<fac89700> ,suspend <tshell>, resume <tidle>!
signal: SIGSUSPEND resume <tidle>
conswitch: S in pid<fcc8d700> ,suspend <tidle>, resume <tshell>!
signal: SIGSUSPEND suspend <tidle>
段错误
| /
- RT - Thread Operating System
/ | 1.2.0 build Jan 15 2013
2006 - 2012 Copyright by rt-thread team
[New Thread 0x7ffff6e37700 (LWP 3839)]
pid <f6e37700> stop on sem...
[New Thread 0x7ffff6636700 (LWP 3840)]
pid <f6636700> stop on sem...
[New Thread 0x7ffff5e35700 (LWP 3841)]
pid <f7fda700> mainthread
pid <f5e35700> stop on sem...
start system tick!
pid <f6e37700> tid <init> starts...
[New Thread 0x7ffff5634700 (LWP 3842)]
pid <f6e37700> tid <init> exit...
conswitch: P in pid<f6e37700> ,suspend <init>, resume <(null)>!
pid <f5634700> stop on sem...
pid <f5634700> tid <tshell> starts...
finsh>>conswitch: P in pid<f5634700> ,suspend <tshell>, resume <(null)>!
pid <f6636700> tid <test> starts...
hello, world
conswitch: P in pid<f6636700> ,suspend <test>, resume <(null)>!
pid <f5e35700> tid <tidle> starts...
pid <f7fda700> signal: SIGALRM enter!
isr: systick enter!
isr: systick leave!
pid <f7fda700> signal: SIGALRM leave!
conswitch: S in pid<f7638700> ,suspend <tidle>, resume <tshell>!
aconswitch: P in pid<f5634700> ,suspend <tshell>, resume <tidle>!
signal: SIGSUSPEND suspend <tshell>
pid <f7fda700> signal: SIGALRM enter!
isr: systick enter!
conswitch: S in pid<f7fda700> ,suspend <tidle>, resume <test>!
isr: systick leave!
pid <f7fda700> signal: SIGALRM leave!
hello, world
conswitch: P in pid<f6636700> ,suspend <test>, resume <tidle>!
conswitch: S in pid<f7638700> ,suspend <tidle>, resume <tshell>!
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff5634700 (LWP 3842)]
0x00000000004117e8 in strcmp (s1=0x0, s2=0x7ffff5633af0 "a") at /home/yangyang/git/rt-thread/rt-thread/components/finsh/shell.c:42
42 /home/yangyang/git/rt-thread/rt-thread/components/finsh/shell.c: 没有那个文件或目录.
in /home/yangyang/git/rt-thread/rt-thread/components/finsh/shell.c
(gdb)