pub fn dispatch(&mut self) -> bool {
    let mut ctx = Context::new(CodePtr::null());

    let mut scheduler = self.scheduler.borrow_mut();
    let curr_p = match scheduler.next_process() {
      None => return false,
      Some(p) => scheduler.lookup_pid_mut(p).unwrap()
    };
    ctx.copy_from(&curr_p.context); // swapin

    loop {
      if cfg!(debug_assertions) {
        print!("[exec] ");
        unsafe { disasm::disasm_op(ctx.ip.get(),
                                   self.code_server.borrow().as_ref()); }
      }

      // Take next opcode
      let op = opcode::from_memory_word(ctx.fetch());
      assert!(op <= gen_op::OPCODE_MAX,
              "Opcode too big (wrong memory address?) got 0x{:x}", op);

      // Handle next opcode
      match dispatch_op_inline(self, op, &mut ctx, curr_p) {
        DispatchResult::Yield => {
          curr_p.context.copy_from(&ctx); // swapout
          curr_p.timeslice_result = SliceResult::Yield;
          return true
        },
        DispatchResult::Error(exc_type, exc_reason) => {
          curr_p.exception(exc_type, exc_reason);
          curr_p.context.copy_from(&ctx); // swapout
          curr_p.timeslice_result = SliceResult::Exception;
          return true
        },
        DispatchResult::Normal => {
          curr_p.timeslice_result = SliceResult::None;
        }, // keep looping
      }
    } // end loop
  }
/// Take a process from scheduler.
/// Fetch an opcode and execute it.
/// Reduce the reduction (instruction) count and once it reaches zero, return.
/// Call dispatch again to schedule another process.
Take a process from scheduler.
Fetch an opcode and execute it.
Reduce the reduction (instruction) count and once it reaches zero, return.
Call dispatch again to schedule another process.
Take a process from scheduler . Fetch an opcode and execute it . Reduce the reduction ( instruction ) count and once it reaches zero return . Call dispatch again to schedule another process .
pub fn dispatch(&mut self) -> bool {
    let mut ctx = Context::new(CodePtr::null());
    let mut scheduler = self.scheduler.borrow_mut();
    let curr_p = match scheduler.next_process() {
      None => return false,
      Some(p) => scheduler.lookup_pid_mut(p).unwrap()
    };
    ctx.copy_from(&curr_p.context); // swapin
    loop {
      if cfg!(debug_assertions) {
        print!("[exec] ");
        unsafe { disasm::disasm_op(ctx.ip.get(),
                                   self.code_server.borrow().as_ref()); }
      }
      // Take next opcode
      let op = opcode::from_memory_word(ctx.fetch());
      assert!(op <= gen_op::OPCODE_MAX,
              "Opcode too big (wrong memory address?) got 0x{:x}", op);
      // Handle next opcode
      match dispatch_op_inline(self, op, &mut ctx, curr_p) {
        DispatchResult::Yield => {
          curr_p.context.copy_from(&ctx); // swapout
          curr_p.timeslice_result = SliceResult::Yield;
          return true
        },
        DispatchResult::Error(exc_type, exc_reason) => {
          curr_p.exception(exc_type, exc_reason);
          curr_p.context.copy_from(&ctx); // swapout
          curr_p.timeslice_result = SliceResult::Exception;
          return true
        },
        DispatchResult::Normal => {
          curr_p.timeslice_result = SliceResult::None;
        }, // keep looping
      }
    } // end loop
  }
pub fn dispatch ( & mut self ) -> bool { let mut ctx = Context :: new ( CodePtr :: null ( ) ) ; let mut scheduler = self . scheduler . borrow_mut ( ) ; let curr_p = match scheduler . next_process ( ) { None => return false , Some ( p ) => scheduler . lookup_pid_mut ( p ) . unwrap ( ) } ; ctx . copy_from ( & curr_p . context ) ; // swapin loop { if cfg ! ( debug_assertions ) { print ! ( " " ) ; unsafe { disasm :: disasm_op ( ctx . ip . get ( ) , self . code_server . borrow ( ) . as_ref ( ) ) ; } } // Take next opcode let op = opcode :: from_memory_word ( ctx . fetch ( ) ) ; assert ! ( op gen_op OPCODE_MAX " " op ) ; // Handle next opcode match dispatch_op_inline ( self , op , & mut ctx , curr_p ) { DispatchResult :: Yield => { curr_p . context . copy_from ( & ctx ) ; // swapout curr_p . timeslice_result = SliceResult :: Yield ; return true } , DispatchResult :: Error ( exc_type , exc_reason ) => { curr_p . exception ( exc_type , exc_reason ) ; curr_p . context . copy_from ( & ctx ) ; // swapout curr_p . timeslice_result = SliceResult :: Exception ; return true } , DispatchResult :: Normal => { curr_p . timeslice_result = SliceResult :: None ; } , // keep looping } } // end loop }
Take a process from scheduler.
Take a process from scheduler .
&mut self