Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PHPmihuan
rt-thread
提交
b8bd5c83
R
rt-thread
项目概览
PHPmihuan
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b8bd5c83
编写于
1月 15, 2013
作者:
P
prife
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug in cpu_port.c(can work very well)
上级
395178eb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
6 deletion
+16
-6
libcpu/sim/posix/cpu_port.c
libcpu/sim/posix/cpu_port.c
+16
-6
未找到文件。
libcpu/sim/posix/cpu_port.c
浏览文件 @
b8bd5c83
...
...
@@ -157,7 +157,7 @@ static void *thread_run(void *parameter)
/* FIXME set signal mask, mask the timer! */
signal_mask
();
thread
->
status
=
SUSPEND_
SIGWAIT
;
thread
->
status
=
SUSPEND_
LOCK
;
TRACE
(
"pid <%08x> stop on sem...
\n
"
,
(
unsigned
int
)(
thread
->
pthread
));
sem_wait
(
&
thread
->
sem
);
...
...
@@ -289,6 +289,9 @@ void rt_hw_interrupt_enable(rt_base_t level)
thread_from
->
rtthread
->
name
,
thread_to
->
rtthread
->
name
);
cpu_pending_interrupts
--
;
thread_from
->
status
=
SUSPEND_LOCK
;
pthread_mutex_unlock
(
ptr_int_mutex
);
/* 唤醒被挂起的线程 */
if
(
thread_to
->
status
==
SUSPEND_SIGWAIT
)
{
...
...
@@ -303,9 +306,6 @@ void rt_hw_interrupt_enable(rt_base_t level)
printf
(
"conswitch: should not be here! %d
\n
"
,
__LINE__
);
exit
(
EXIT_FAILURE
);
}
cpu_pending_interrupts
--
;
thread_from
->
status
=
SUSPEND_LOCK
;
pthread_mutex_unlock
(
ptr_int_mutex
);
/* 挂起当前的线程 */
sem_wait
(
&
thread_from
->
sem
);
...
...
@@ -325,9 +325,20 @@ void rt_hw_interrupt_enable(rt_base_t level)
(
unsigned
int
)
pid
,
thread_from
->
rtthread
->
name
,
thread_to
->
rtthread
->
name
);
cpu_pending_interrupts
--
;
/* 需要把解锁函数放在前面,以防止死锁?? */
pthread_mutex_unlock
(
ptr_int_mutex
);
/* 挂起from线程 */
pthread_kill
(
thread_from
->
pthread
,
MSG_SUSPEND
);
cpu_pending_interrupts
--
;
/* TODO 这里需要确保线程被挂起了, 否则304行就很可能就会报错退出
* 因为这里挂起线程是通过信号实现的,所以一定要确保线程挂起才行 */
while
(
thread_from
->
status
!=
SUSPEND_SIGWAIT
)
{
sched_yield
();
}
/* 唤醒to线程 */
if
(
thread_to
->
status
==
SUSPEND_SIGWAIT
)
...
...
@@ -344,7 +355,6 @@ void rt_hw_interrupt_enable(rt_base_t level)
exit
(
EXIT_FAILURE
);
}
pthread_mutex_unlock
(
ptr_int_mutex
);
}
/*TODO: It may need to unmask the signal */
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录