Skip to content

Commit

Permalink
fix #8 by checking if scheduler thread is running
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzh committed Feb 28, 2020
1 parent 2e377f0 commit 5ae0cd9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TYPE=release
RELEASE_FLAG=--release
TYPE=debug
RELEASE_FLAG=
K=kernel/src
U=user/src
TARGET=riscv64gc-unknown-none-elf
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ multiple boards.
- [ ] Allocator and stdlib in user-space
- [ ] (WIP) Implement wait syscall
- [ ] Simple shell
- [ ] **(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.)
- [x] Investigate frequent kernel panic ([#8](https://github.com/skyzh/core-os-riscv/issues/8))
- [ ] Reimplement process scheduling system ([#9](https://github.com/skyzh/core-os-riscv/issues/9))
* Filesystem
- [x] Fake fs and exec system call
- [x] Real spinlock instead of nulllock
Expand Down
1 change: 1 addition & 0 deletions kernel/src/process/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub fn sched() {
let ctx = core::mem::replace(&mut c.scheduler_context, Context::zero());

let intena = c.intr_lock.is_enabled_before;

swtch(&mut p.context, ctx);
c.intr_lock.is_enabled_before = intena;
}
Expand Down
10 changes: 6 additions & 4 deletions kernel/src/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ extern "C" fn kerneltrap() {
};

if dev_intr == Some(Timer) {
let p = &my_cpu().process;
if let Some(p) = p {
if p.state == process::ProcessState::RUNNING {
yield_cpu();
if my_cpu().scheduler_context.regs[0] != 0 {
let p = &my_cpu().process;
if let Some(p) = p {
if p.state == process::ProcessState::RUNNING {
yield_cpu();
}
}
}
}
Expand Down

0 comments on commit 5ae0cd9

Please sign in to comment.