Beispiel #1
0
int builtin_bg(int argc, char **argv, int in, int out, int err){

  /* Chop of the command. We don't care about it. */
  ++argv;
  --argc;

  /* Now, we just try and foreground the top of the process group queue. That
   * is to say the last of the processg group queue.
   */
  int state = 0;
  struct rsh_process *proc;
  struct rsh_process *bg_proc;
  
  while ( (proc = get_next_proc(&state)) != NULL ){
    if ( ! proc->running )
      bg_proc = proc;
  }

  /* No processes to foreground. */
  if ( ! bg_proc ){
    printf("No process to background.\n");
    return 0;
  }

  /* fg_proc is the last process to come out of the process list that is not
   * running. We will run it in the background here. */
  background(bg_proc);
  return 0;

}
Beispiel #2
0
/*
 * Display the list of processes that RSH is aware of (child processes).
 */
int builtin_dproc(int argc, char **argv, int in, int out, int err){

  int state = 0;
  struct rsh_process *proc;
  
  while ( (proc = get_next_proc(&state)) != NULL ){

    printf("pid %-5ld (%s): %s\n", (long)proc->pid, 
	   proc->running ? "running" : "stopped", proc->name);

  }

  return 0;

}
Beispiel #3
0
void timer_handler() {
	uint64_t 	tmp = usec;
	uint32_t 	tmpSec = 0;
	uint32_t 	tmpMin = 0;
	uint32_t 	sec = 0;
	uint32_t 	min = 0;
	uint32_t 	hour = 0;

	if(tmp >= 100) {
		sec = tmp / 100;
		tmpSec = sec % 60;
	} 
	if(sec >= 60) {
		min = sec / 60;
		tmpMin = min % 60;
	}
	if(min >= 60) {
		hour = min / 60;
	}
	tmp %= 100;
	tmp += (tmpSec*100);
	tmp += (tmpMin*10000);
	tmp += (hour*1000000);

    time_write(tmp);
    usec++;
    pic_sendEOI(32);
    offset = 0;
    colon = 0;

    //---------------------- scheduler --------------------------
    uint64_t			cur_rsp;
    task_struct			*next_proc;
    task_struct			*prev_proc = cur_proc;

    //when scheduler is on
    if(schedule_flag) {
    	sleep_cnt_update();

    	if(!cur_proc) {
			next_proc = get_next_proc();
			//printf("next_proc: %p\n", next_proc);
			//printf("next_proc->proc_name: %s\n", next_proc->proc_name);
			//printf("next_proc->rsp: %p\n", next_proc->rsp);
	 		//context_switch(next_proc);
	 		load_cr3(next_proc->mm_struct->pgd_t);
			//in_rsp(next_proc->rsp);
			if (next_proc->mode == USER) {
		    	//tss.rsp0 = (uint64_t)&next_proc->k_stack[511]; //the top addr of the stack
		    	//switch_to_ring3();
		    }

    	} else {
    		//store the rsp position before switch
	    	cur_rsp = out_rsp();
	 		prev_proc->rsp = cur_rsp;
	 		add_proc(prev_proc);
	 		next_proc = get_next_proc();
	 		//context_switch(next_proc);
	 		load_cr3(next_proc->mm_struct->pgd_t);
			//in_rsp(next_proc->rsp);
			if (next_proc->mode == USER) {
		    	//tss.rsp0 = (uint64_t)&next_proc->k_stack[511]; //the top addr of the stack
		    	//switch_to_ring3();
		    }
	    }
    } 
}