Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr_Pangza
rt-thread
提交
5e69accd
R
rt-thread
项目概览
Mr_Pangza
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
未验证
提交
5e69accd
编写于
12月 23, 2020
作者:
B
Bernard Xiong
提交者:
GitHub
12月 23, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4187 from Jedcheen/master
fix scheduler bug in simulator.
上级
b10815c0
82ae97e2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
2 deletion
+24
-2
libcpu/sim/win32/cpu_port.c
libcpu/sim/win32/cpu_port.c
+22
-0
libcpu/sim/win32/cpu_port.h
libcpu/sim/win32/cpu_port.h
+2
-2
未找到文件。
libcpu/sim/win32/cpu_port.c
浏览文件 @
5e69accd
...
...
@@ -27,6 +27,8 @@
* The context switch is managed by the threads.So the task stack does not have to be managed directly,
* although the stack stack is still used to hold an WinThreadState structure this is the only thing it
* will be ever hold.
* YieldEvent used to make sure the thread does not execute before asynchronous SuspendThread() operation
* actually being performed.
* the structure indirectly maps the task handle to a thread handle
*********************************************************************************************************
*/
...
...
@@ -35,6 +37,7 @@ typedef struct
void
*
Param
;
//Thread param
void
(
*
Entry
)(
void
*
);
//Thread entry
void
(
*
Exit
)(
void
);
//Thread exit
HANDLE
YieldEvent
;
HANDLE
ThreadHandle
;
DWORD
ThreadID
;
}
win_thread_t
;
...
...
@@ -171,6 +174,11 @@ rt_uint8_t* rt_hw_stack_init(void *pEntry,void *pParam,rt_uint8_t *pStackAddr,vo
pWinThread
->
ThreadHandle
=
NULL
;
pWinThread
->
ThreadID
=
0
;
pWinThread
->
YieldEvent
=
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
/* Create the winthread */
pWinThread
->
ThreadHandle
=
CreateThread
(
NULL
,
0
,
...
...
@@ -277,6 +285,19 @@ void rt_hw_context_switch(rt_uint32_t from,
//trigger YIELD exception(cause contex switch)
TriggerSimulateInterrupt
(
CPU_INTERRUPT_YIELD
);
// make sure the event is not already signaled
win_thread_t
*
WinThread
=
(
win_thread_t
*
)
rt_interrupt_from_thread
;
ResetEvent
(
WinThread
->
YieldEvent
);
/*
* enable interrupt in advance so that scheduler can be executed.please note that interrupt
* maybe disable twice before.
*/
rt_hw_interrupt_enable
(
0
);
rt_hw_interrupt_enable
(
0
);
// wait to suspend.
WaitForSingleObject
(
WinThread
->
YieldEvent
,
INFINITE
);
}
/*** rt_hw_context_switch ***/
/*
...
...
@@ -578,6 +599,7 @@ void RegisterSimulateInterrupt(rt_uint32_t IntIndex,rt_uint32_t (*IntHandler)(vo
if
((
WinThreadFrom
!=
NULL
)
&&
(
WinThreadFrom
->
ThreadHandle
!=
NULL
))
{
SuspendThread
(
WinThreadFrom
->
ThreadHandle
);
SetEvent
(
WinThreadFrom
->
YieldEvent
);
}
ResumeThread
(
WinThreadTo
->
ThreadHandle
);
...
...
libcpu/sim/win32/cpu_port.h
浏览文件 @
5e69accd
...
...
@@ -17,8 +17,8 @@
* CPU INTERRUPT PRIORITY
*********************************************************************************************************
*/
#define CPU_INTERRUPT_YIELD 0x0
0
#define CPU_INTERRUPT_TICK 0x0
1
#define CPU_INTERRUPT_YIELD 0x0
1 // should be set to the lowest priority.
#define CPU_INTERRUPT_TICK 0x0
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录