Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rcore-os
RCore Tutorial V3
提交
ddc21343
R
RCore Tutorial V3
项目概览
rcore-os
/
RCore Tutorial V3
上一次同步 1 年多
通知
15
Star
793
Fork
260
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RCore Tutorial V3
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ddc21343
编写于
5月 01, 2022
作者:
chyyuu1972
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix kernel thread, task.rs -- Line:93 -- kstack --> kstack:KernelStack(kstack_top). run correctly
上级
2166fecf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
20 deletion
+11
-20
os/src/main.rs
os/src/main.rs
+1
-1
os/src/task/context.rs
os/src/task/context.rs
+0
-8
os/src/task/id.rs
os/src/task/id.rs
+4
-1
os/src/task/mod.rs
os/src/task/mod.rs
+2
-2
os/src/task/task.rs
os/src/task/task.rs
+4
-8
未找到文件。
os/src/main.rs
浏览文件 @
ddc21343
...
...
@@ -54,8 +54,8 @@ pub fn rust_main() -> ! {
trap
::
enable_timer_interrupt
();
timer
::
set_next_trigger
();
task
::
stackless_coroutine
::
kernel_stackless_coroutine_test
();
task
::
kernel_stackful_coroutine_test
();
fs
::
list_apps
();
task
::
kernel_stackful_coroutine_test
();
task
::
add_initproc
();
task
::
run_tasks
();
panic!
(
"Unreachable in rust_main!"
);
...
...
os/src/task/context.rs
浏览文件 @
ddc21343
...
...
@@ -16,14 +16,6 @@ impl TaskContext {
}
}
pub
fn
kthread_init
()
->
Self
{
Self
{
ra
:
0xAAAAAAAA
,
sp
:
0xBBBBBBBB
,
s
:
[
0xCCCCCCCC
;
12
],
}
}
pub
fn
goto_trap_return
(
kstack_ptr
:
usize
)
->
Self
{
Self
{
ra
:
trap_return
as
usize
,
...
...
os/src/task/id.rs
浏览文件 @
ddc21343
use
super
::
ProcessControlBlock
;
use
crate
::
config
::{
KERNEL_STACK_SIZE
,
PAGE_SIZE
,
TRAMPOLINE
,
TRAP_CONTEXT_BASE
,
USER_STACK_SIZE
};
use
crate
::
mm
::{
MapPermission
,
PhysPageNum
,
VirtAddr
,
KERNEL_SPACE
};
use
crate
::
mm
::{
MapPermission
,
PhysPageNum
,
VirtAddr
,
KERNEL_SPACE
,
PhysAddr
};
use
crate
::
sync
::
UPSafeCell
;
use
alloc
::{
sync
::{
Arc
,
Weak
},
...
...
@@ -70,6 +70,7 @@ pub struct KernelStack(pub usize);
pub
fn
kstack_alloc
()
->
KernelStack
{
let
kstack_id
=
KSTACK_ALLOCATOR
.exclusive_access
()
.alloc
();
let
(
kstack_bottom
,
kstack_top
)
=
kernel_stack_position
(
kstack_id
);
//println!("kstack_alloc kstack_bottom: {:#x?}, kstack_top: {:#x?}", kstack_bottom, kstack_top);
KERNEL_SPACE
.exclusive_access
()
.insert_framed_area
(
kstack_bottom
.into
(),
kstack_top
.into
(),
...
...
@@ -82,6 +83,8 @@ impl Drop for KernelStack {
fn
drop
(
&
mut
self
)
{
let
(
kernel_stack_bottom
,
_
)
=
kernel_stack_position
(
self
.0
);
let
kernel_stack_bottom_va
:
VirtAddr
=
kernel_stack_bottom
.into
();
// let kernel_stack_bottom_pa: PhysAddr = kernel_stack_bottom.into();
// println!("kstack_drop kstack_bottom: va: {:#x?}, pa: {:#x?}", kernel_stack_bottom_va, kernel_stack_bottom_pa);
KERNEL_SPACE
.exclusive_access
()
.remove_area_with_start_vpn
(
kernel_stack_bottom_va
.into
());
...
...
os/src/task/mod.rs
浏览文件 @
ddc21343
...
...
@@ -138,12 +138,12 @@ pub fn kthread_create(f: fn()) {
println!
(
"kthread_create"
);
//
�����ں��߳�
//
create kernel thread
let
new_tcb
=
TaskControlBlock
::
create_kthread
(
f
);
// let kernel_stack = new_tcb.get_kernel_stack();
let
new_task
=
Arc
::
new
(
new_tcb
);
//
��������������,���û��̷߳���һ�����.
//
add kernel thread into TASK_MANAGER
// println!("add task");
add_task
(
Arc
::
clone
(
&
new_task
));
}
...
...
os/src/task/task.rs
浏览文件 @
ddc21343
...
...
@@ -23,11 +23,6 @@ impl TaskControlBlock {
let
inner
=
process
.inner_exclusive_access
();
inner
.memory_set
.token
()
}
// pub fn get_kernel_stack(&self) -> usize {
// self.kstack
// }
}
pub
struct
TaskControlBlockInner
{
...
...
@@ -83,7 +78,7 @@ impl TaskControlBlock {
let
kernelstack
=
crate
::
task
::
id
::
KStack
::
new
();
let
kstack_top
=
kernelstack
.top
();
let
mut
context
=
TaskContext
::
kthread
_init
();
let
mut
context
=
TaskContext
::
zero
_init
();
let
context_addr
=
&
context
as
*
const
TaskContext
as
usize
;
let
pa
=
PhysAddr
::
from
(
context_addr
);
let
context_ppn
=
pa
.floor
();
...
...
@@ -91,11 +86,12 @@ impl TaskControlBlock {
context
.ra
=
f
as
usize
;
context
.sp
=
kstack_top
;
println!
(
"context ppn :{:#x?}"
,
context_ppn
);
//
println!("context ppn :{:#x?}", context_ppn);
Self
{
process
,
kstack
,
kstack
:
KernelStack
(
kstack_top
),
//kstack,
inner
:
unsafe
{
UPSafeCell
::
new
(
TaskControlBlockInner
{
res
:
None
,
...
...
Miykael_xxm
🚴
@xiongjiamu
mentioned in commit
080c0c8e
·
5月 02, 2022
mentioned in commit
080c0c8e
mentioned in commit 080c0c8e55d08e0b132cc3d085bd23854b8a44f4
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录