Skip to content

Commit 5ae0cd9

Browse files
committed
fix skyzh#8 by checking if scheduler thread is running
1 parent 2e377f0 commit 5ae0cd9

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
TYPE=release
2-
RELEASE_FLAG=--release
1+
TYPE=debug
2+
RELEASE_FLAG=
33
K=kernel/src
44
U=user/src
55
TARGET=riscv64gc-unknown-none-elf

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ multiple boards.
9494
- [ ] Allocator and stdlib in user-space
9595
- [ ] (WIP) Implement wait syscall
9696
- [ ] Simple shell
97-
- [ ] **(WIP) Investigate frequent kernel panic ([#8](https://github.com/skyzh/core-os-riscv/issues/8))** (I'm mad about this one. I don't know what triggered kernel panic. The kernel just stop at kernelvec.)
97+
- [x] Investigate frequent kernel panic ([#8](https://github.com/skyzh/core-os-riscv/issues/8))
98+
- [ ] Reimplement process scheduling system ([#9](https://github.com/skyzh/core-os-riscv/issues/9))
9899
* Filesystem
99100
- [x] Fake fs and exec system call
100101
- [x] Real spinlock instead of nulllock

kernel/src/process/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub fn sched() {
5555
let ctx = core::mem::replace(&mut c.scheduler_context, Context::zero());
5656

5757
let intena = c.intr_lock.is_enabled_before;
58+
5859
swtch(&mut p.context, ctx);
5960
c.intr_lock.is_enabled_before = intena;
6061
}

kernel/src/trap.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ extern "C" fn kerneltrap() {
102102
};
103103

104104
if dev_intr == Some(Timer) {
105-
let p = &my_cpu().process;
106-
if let Some(p) = p {
107-
if p.state == process::ProcessState::RUNNING {
108-
yield_cpu();
105+
if my_cpu().scheduler_context.regs[0] != 0 {
106+
let p = &my_cpu().process;
107+
if let Some(p) = p {
108+
if p.state == process::ProcessState::RUNNING {
109+
yield_cpu();
110+
}
109111
}
110112
}
111113
}

0 commit comments

Comments
 (0)