1+ use crate :: arch:: Thread ;
12use crate :: memory:: { ActivePageTable , FrameAllocator , InActivePageTable } ;
23use core:: mem;
34use core:: ptr;
@@ -6,13 +7,15 @@ use spin::Mutex;
67
78struct Process {
89 page_table : InActivePageTable ,
10+ thread : Thread ,
911}
1012
1113impl Process {
1214 fn new ( allocator : & mut FrameAllocator ) -> Process {
1315 // FIXME: remove 1st argument (ActivePageTable).
1416 Process {
1517 page_table : InActivePageTable :: new ( unsafe { & mut ActivePageTable :: new ( ) } , allocator) . unwrap ( ) ,
18+ thread : Thread :: new ( ) ,
1619 }
1720 }
1821}
@@ -40,29 +43,10 @@ lazy_static! {
4043 static ref PROCESS_MANAGER : Mutex <ProcessManager > = Mutex :: new( ProcessManager :: new( ) ) ;
4144}
4245
43- pub fn switch_process ( ) {
44- // let mut current_ip = 0;
45- // let mut current_sp = 0;
46- // let mut next_ip = 0;
47- // let mut next_sp = 0;
48- // unsafe {
49- // asm!("
50- // pushf
51- //
52- // mov [$0], $2
53- // mov [$1], rsp
54- // "
55- // : "=r"(&mut current_ip) "=r"(&mut current_sp)
56- // : "r"(landing_point as usize)
57- // : "memory"
58- // : "intel", "volatile");
59- // }
60- //
61- // println!("{}", current_ip);
62- // println!("{}", current_sp);
46+ pub fn select_threads < F > ( mut switch_context : F )
47+ where
48+ F : FnMut ( ) ,
49+ {
50+ // TODO: pass current process and next process.
51+ switch_context ( ) ;
6352}
64-
65- // #[no_mangle]
66- // pub extern "C" fn landing_point() {
67- // unsafe { asm!("popf") }
68- // }
0 commit comments