Пример #1
0
void sys_exit()
{  
/*
a) Free the data structures and resources of this process (physical memory, task_struct,
   and so). It uses the free_frame function to free physical pages.
b) Use the scheduler interface to select a new process to be executed and make a context
   switch.*/
  update_user_to_system();   
  free_user_pages(current());  
	update_current_state_rr(&freequeue);
	sched_next_rr();                                 
}
Пример #2
0
 * 使用次数,若是共享的,则分配一个新的页目录,并将原页目录引用数减1。
 */
BOOL pre_replace_user_zone(void)
{
	free_user_pages(current->code_start,
		current->data_end-current->code_start, 1);
	if(1 < mem_map[M2MAP(current->tss.cr3)]) {
		unsigned long addr = current->tss.cr3;
		if(!copy_kernel_page_dir(&(current->tss.cr3))) {
			k_printf("free_user_zone: have no free-page!");
			return FALSE;
		}
		load_cr3(current->tss.cr3);
		--mem_map[M2MAP(addr)];
		d_printf("set cr3 finished, cr3 = %x.\n", current->tss.cr3);
	}