Skip to content

Commit

Permalink
Merge #495
Browse files Browse the repository at this point in the history
495: [Closes #443] Safe list that does not own its nodes r=Medowhill a=travis1829

Closes #443 

#443 을 `Branded`를 사용하지 않는 다른 방법으로 해결해보았습니다.
핵심은 다음과 같습니다.
* `NodeRef`, `NodeMut`는 `Node`가 `List` 안에 있는 동안에만 존재합니다.
* `NodeRef`를 얻으려면, 항상 1) `NodeRef`와 2) `ListRef`가 둘다 필요합니다.
* `NodeMut`를 얻으려면, 항상 1) `NodeMut`와 2) `ListMut`가 둘다 필요합니다.
* 하나의 `List`에 대해, `NodeMut`는 항상 단 한개만 존재합니다.
* `Node`가 `List`안에 있는 상태에서 drop되면 panic합니다. (유일한 runtime cost)

이렇게 하면, lifetime 제한이나 functionality 제한 등을 걸지 않더라도 linked list를 safe하게 구현할 수 있습니다.

Co-authored-by: travis1829 <travis1829@naver.com>
  • Loading branch information
kaist-cp-bors[bot] and travis1829 authored Apr 30, 2021
2 parents 81c9dc6 + c084d1b commit b946a94
Show file tree
Hide file tree
Showing 5 changed files with 909 additions and 220 deletions.
2 changes: 1 addition & 1 deletion kernel-rs/src/arena/mru_arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use pin_project::pin_project;
use super::{Arena, ArenaObject, ArenaRef, Handle, HandleRef, Rc};
use crate::{
lock::{Spinlock, SpinlockGuard},
util::list::{List, ListEntry, ListNode},
util::intrusive_list::{List, ListEntry, ListNode},
util::pinned_array::IterPinMut,
util::rc_cell::{RcCell, RefMut},
};
Expand Down
2 changes: 1 addition & 1 deletion kernel-rs/src/kalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
arch::memlayout::PHYSTOP,
lock::Spinlock,
page::Page,
util::list::{List, ListEntry, ListNode},
util::intrusive_list::{List, ListEntry, ListNode},
};

extern "C" {
Expand Down
Loading

0 comments on commit b946a94

Please sign in to comment.