• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setupkvm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setupkvm函数的典型用法代码示例。如果您正苦于以下问题:C++ setupkvm函数的具体用法?C++ setupkvm怎么用?C++ setupkvm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setupkvm函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];

  p = allocproc();
  
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  // this assignment to p->state lets other cores
  // run this process. the acquire forces the above
  // writes to be visible, and the lock is also needed
  // because the assignment might not be atomic.
  acquire(&ptable.lock);

  p->state = RUNNABLE;

  release(&ptable.lock);
}
开发者ID:buf1024,项目名称:xv6-public,代码行数:37,代码来源:proc.c


示例2: copyuvm

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  pde_t *d = setupkvm();
  pte_t *pte;
  uint pa, i;
  char *mem;

  if(!d) return 0;
  for(i = 0; i < sz; i += PGSIZE){
    if(!(pte = walkpgdir(pgdir, (void *)i, 0)))
      panic("copyuvm: pte should exist\n");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present\n");
    pa = PTE_ADDR(*pte);
    if(!(mem = kalloc()))
      goto bad;
    memmove(mem, (char *)pa, PGSIZE);
    if(!mappages(d, (void *)i, PGSIZE, PADDR(mem), PTE_W|PTE_U))
      goto bad;
  }
  return d;

bad:
  freevm(d);
  return 0;
}
开发者ID:treejames,项目名称:xv6,代码行数:29,代码来源:vm.c


示例3: userinit

// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  acquire(&ptable.lock);
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  p->state = RUNNABLE;
  release(&ptable.lock);
}
开发者ID:malichan,项目名称:cs537-project,代码行数:29,代码来源:proc.c


示例4: copyuvm

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  pde_t *d;
  pte_t *pte;
  uint pa, i, flags;
  char *mem;

  if((d = setupkvm()) == 0)
    return 0;
  for(i = 0; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    flags = PTE_FLAGS(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)p2v(pa), PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, v2p(mem), flags) < 0)
      goto bad;
  }
  return d;

bad:
  freevm(d);
  return 0;
}
开发者ID:DoctorWkt,项目名称:xv6-freebsd,代码行数:31,代码来源:vm.c


示例5: userinit

//PAGEBREAK: 32
// Set up first user process.
void userinit(void) {
	struct proc *p;
	extern char _binary_initcode_start[], _binary_initcode_size[];

	p = allocproc();

	initproc = p;
	if ((p->pgdir = setupkvm()) == 0)
		panic("userinit: out of memory?");
	inituvm(p->pgdir, _binary_initcode_start, (int) _binary_initcode_size);
	p->sz = PGSIZE;
	memset(p->tf, 0, sizeof(*p->tf));
	p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
	p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
	p->tf->es = p->tf->ds;
	p->tf->ss = p->tf->ds;
	p->tf->eflags = FL_IF;
	p->tf->esp = PGSIZE;
	p->tf->eip = 0; // beginning of initcode.S

	safestrcpy(p->name, "initcode", sizeof(p->name));
	p->cwd = namei("/");


	p->parent=0;
	setpriority(p,0);
	SetProcessRunnable(p);
}
开发者ID:jahandideh-iman,项目名称:XV6_Scheduling,代码行数:30,代码来源:proc.c


示例6: kvmalloc

// Allocate one page table for the machine for the kernel address
// space for scheduler processes.
void
kvmalloc(void)
{
  kpgdir = setupkvm();
  if(kpgdir == 0)
    panic("kvmalloc: could not create kernel page table");
  switchkvm();
}
开发者ID:baileyparker,项目名称:xv6-public,代码行数:10,代码来源:vm.c


示例7: kvmalloc

void
kvmalloc(void)
{
    if ((kpgmap = setupkvm()) == nil)
        panic("kvmalloc");

    switchkvm();
}
开发者ID:davidbalbert,项目名称:thimble,代码行数:8,代码来源:vm.c


示例8: copyuvm

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  pde_t *d;
  pte_t *pte;
  uint pa, i;
  char *mem;

  if((d = setupkvm()) == 0)
    return 0;
  //<(-
  //CHANGED i = 0, < sz
  for(i = PGSIZE; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 1)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P)){
      panic("copyuvm: page not present");
    }
    else{
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
    }
  }
  cprintf("Last addr copied from code: %x\n", i-PGSIZE);

  //copy stack
 for(i = USERTOP-proc->stacksz; i < USERTOP; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 1)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P)){
      panic("copyuvm: page not present");
    }
    else{
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
    }
  }
  cprintf("Last addr copied from code: %x\n", i-PGSIZE);
  return d;

bad:
  freevm(d);
  return 0;
}
开发者ID:jimbokroneus,项目名称:OS-Projects,代码行数:54,代码来源:vm.c


示例9: copyuvm

// TODO(byan23): Copy the stack at the end of addr space.
// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  pde_t *d;
  pte_t *pte;
  uint pa, i;
  char *mem;

  if((d = setupkvm()) == 0)
    return 0;
  // Copy code + heap.
  if (proc->pid == 1) i = 0;
  else i = PGSIZE;
  for(; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
  }
  //cprintf("before coping stack from pid %d.\n", proc->pid);
  // TODO(byan23): Copy more stack as it grows.
  // Copy stack.
  i = USERTOP - proc->ssz;
  //i = USERTOP - PGSIZE;
  if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
    panic("copyuvm: pte should exist");
  if(!(*pte & PTE_P))
    panic("copyuvm: page not present");
  pa = PTE_ADDR(*pte);
  if((mem = kalloc()) == 0)
    goto bad;
  memmove(mem, (char*)pa, PGSIZE);
  if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
    goto bad;
  
  return d;

bad:
  freevm(d);
  return 0;
}
开发者ID:byan23,项目名称:OS_P3,代码行数:50,代码来源:vm.c


示例10: copyuvm

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  pde_t *d;
  pte_t *pte;
  uint pa, i;
  char *mem;

  if((d = setupkvm()) == 0)
    return 0;
  // cs537
  for(i = PGSIZE; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
  }

  // cs537
  /* copy stack region */

  for(i = proc->sb; i < USERTOP ; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);

    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
  }

  return d;

bad:
  freevm(d);
  return 0;
}
开发者ID:xiqi,项目名称:top-secret-is-public,代码行数:49,代码来源:vm.c


示例11: copyuvm

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz, uint s_sz)
{
  pde_t *d;
  pte_t *pte;
  uint pa, i, stack_size;
  char *mem;

  if((d = setupkvm()) == 0)
    return 0;
  
  // Start at PGSIZE to make the first page invalid
  for(i = PGSIZE; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
  }

  // We need to loop again to copy the stack over
  stack_size = s_sz;
  for(i = stack_size; i < USERTOP; i+= PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
  }
  
  return d;

bad:
  freevm(d);
  return 0;
}
开发者ID:rscarson14,项目名称:cs537-P3,代码行数:48,代码来源:vm.c


示例12: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];

#ifdef USE_CS333_SCHEDULER	// Initialize free list
  acquire(&ptable.lock);
  int i;
  for (i=0; i<NPROC; i++)
    addToFreeList(&ptable.proc[i]);
  release(&ptable.lock);
#endif
  p = allocproc();
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");
  p->uid = DEF_UID;
  p->gid = DEF_GID;

#ifdef USE_CS333_SCHEDULER	// Initialize ready list with init process
  acquire(&ptable.lock);
  p->state = RUNNABLE;
  if (!setPri(p, DEF_PRI))
    cprintf("ERROR: DEF_PRI invalid. Must be between 0 and %d. Current value: %d.\n", N_PRI, DEF_PRI);
  addToPriQ(p, p->pri);
  release(&ptable.lock);
#else
  p->state = RUNNABLE;
#endif
}
开发者ID:ConnorReilly,项目名称:xv6-psu-kernel-repos,代码行数:46,代码来源:proc.c


示例13: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
#ifdef CS333_SCHEDULER
  acquire(&ptable.lock);
  initFreeList();
  ptable.timeToReset = COUNT;
  release(&ptable.lock);
#endif
  
  p = allocproc();
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S
  p->uid = USERID;
  p->gid = GROUPID;

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  p->state = RUNNABLE;
#ifdef CS333_SCHEDULER
  acquire(&ptable.lock);
  int i;
  for (i = 0; i < 3; ++i) {
      ptable.readyList[i] = 0;
  }
  putOnReadyList(p, p->priority);
  release(&ptable.lock);
#endif
}
开发者ID:RickyV33,项目名称:XV6-Operating-System,代码行数:45,代码来源:proc.c


示例14: copyuvm

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz, uint stack_addr)
{
  pde_t *d;
  pte_t *pte;
  uint pa, i;
  char *mem;

  if((d = setupkvm()) == 0)
    return 0;
  for(i = PGSIZE; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, (void*)i, 0)) == 0)
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    pa = PTE_ADDR(*pte);
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE);
    if(mappages(d, (void*)i, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)
      goto bad;
  }

  	  //   Copy the last page which is the new stack
    if((pte = walkpgdir(pgdir, (void*)(USERTOP-PGSIZE), 1)) == 0)//undestand what pgdir does
      panic("copyuvm: pte should exist");
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present");
    //cprintf(" last page is %d\n",pte);
    pa = PTE_ADDR(*pte);// what pa are they getting from pte
    if((mem = kalloc()) == 0)
      goto bad;
    memmove(mem, (char*)pa, PGSIZE); // copying some stuff.. figure out what 1 page is and copying it
    if(mappages(d, (void*)USERTOP-PGSIZE, PGSIZE, PADDR(mem), PTE_W|PTE_U) < 0)//mapping into new address space and making it valid
      goto bad;

    return d;
bad:
  freevm(d);
  return 0;
}
开发者ID:shreyakamath2311,项目名称:Xv6-StackRelocation-ExceptionHandling,代码行数:43,代码来源:vm.c


示例15: copyuvm

Pml4e *
copyuvm(Pml4e *oldmap, usize sz)
{
    uintptr a;
    Pml4e *newmap;
    Pte *pte;
    uchar *oldmem, *newmem;
    uint flags;

    newmap = setupkvm();
    if (newmap == nil)
        return nil;

    for (a = 0; a < sz; a += PGSIZE) {
        pte = walkpgmap(oldmap, (void *)a, 0);
        if (pte == nil)
            panic("copyuvm - nil pte");
        if (!*pte & PTE_P)
            panic("copyuvm - page not present");

        oldmem = p2v(pte_addr(*pte));
        flags = pte_flags(*pte);

        newmem = kalloc();
        if (newmem == nil)
            goto bad;

        memmove(newmem, oldmem, PGSIZE);

        if (mappages(newmap, (void *)a, PGSIZE, v2p(newmem), flags) < 0)
            goto bad;
    }

    return newmap;

bad:
    freeuvm(newmap);
    return nil;
}
开发者ID:davidbalbert,项目名称:thimble,代码行数:39,代码来源:vm.c


示例16: userinit

//PAGEBREAK: 32
// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  initproc = p;
  if((p->pgdir = setupkvm()) == 0)
    panic("userinit: out of memory?");
  inituvm(p->pgdir, p->asid, _binary_initcode_start, (int)_binary_initcode_size);
  p->sz = PGSIZE;
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->sp = PGSIZE;
  p->tf->status = (read_cop0_status() | STATUS_KSU_USER | STATUS_EXL | STATUS_IE) & ~STATUS_ERL;
  p->tf->epc = (uint)0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");

  p->state = RUNNABLE;
}
开发者ID:msyksphinz,项目名称:xv6-mips,代码行数:24,代码来源:proc.c


示例17: userinit

void
userinit(void)
{
    struct proc *p;
    extern char _binary_kernel_initcode_start[],
            _binary_kernel_initcode_size[];
    char *mem;

    p = allocproc();
    assert(p);

    initproc = p;
    if((p->pgdir = setupkvm(kalloc)) == NULL)
        panic("userinit: out of memory?");

    if ((int)_binary_kernel_initcode_size > PGSIZE)
        panic("inituvm: initcode more than a page");

    mem = kalloc();
    memset(mem, 0, PGSIZE);
    mappages(p->pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U, kalloc);
    memcpy(mem, (char *)_binary_kernel_initcode_start,
           (int)_binary_kernel_initcode_size);

    safestrcpy(p->name, "initcode", sizeof(p->name));
    p->brk = PGSIZE;
    memset(p->tf, 1, sizeof(*p->tf));
    p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
    p->tf->ss = (SEG_UDATA << 3) | DPL_USER;
    p->tf->ds = p->tf->es =
            p->tf->fs = p->tf->gs = p->tf->ss;
    p->tf->eflags = FL_IF;
    p->tf->esp = PGSIZE;
    p->tf->eip = 0;  // beginning of initcode

    p->counter = p->priority = 10;
    p->state = RUNNABLE;
}
开发者ID:leadingtheway,项目名称:Jix,代码行数:38,代码来源:proc.c


示例18: load_proc

static int load_proc(char *path, struct proc *p)
{
	int i;
	struct proc np;
	//an inode describes a single unnamed file
	struct inode *ip;
	begin_op();
	if ((ip = namei(path)) == 0) {
		end_op();
		return -1;
	}
	ilock(ip);
	if((np.pgdir = setupkvm()) == 0)
		return -1;
	if((np.sz = allocuvm(np.pgdir, 0, p->sz)) == 0)
		return -1;
	for(i = 0; i < p->sz; i+=PGSIZE) {
		if(loaduvm(np.pgdir, (void *)i, ip, sizeof(struct proc) + i,PGSIZE) < 0)	
	return -1;
	}
	iunlockput(ip);
	end_op();
	ip = 0;
	
	np.tf->eax = proc->pid;
	np.tf->eip = p->tf->eip;
	np.tf->esp = p->tf->esp;
	np.tf->ebp = p->tf->ebp;
	
	proc->pgdir = np.pgdir;
	proc->sz = PGROUNDUP(np.sz);
	*proc->tf = *np.tf;
	
	switchuvm(proc);
	
	return 0;
}
开发者ID:mehrandabi,项目名称:OSProject,代码行数:37,代码来源:loadProc.c


示例19: swapIn

void swapIn(struct proc* p){
//   cprintf("swapIN\n");
  //create flie
  char id_as_str[3]; // need to pre determine number of digits in p->pid
  itoa(p->pid,id_as_str);
  char path[strlen(id_as_str) + 5];
  path[6] = '\0';
//   path[0] = '/';
  strcat(path,0,id_as_str,".swap");
  //cprintf("swapIn - passed strcat path: %s\n",path);
  release(&ptable.lock);
  int test;
  p->swapped_file = kernel_open(path,O_RDONLY);
//   p->swapped_file = p->ofile[p->swapped_file_fd];
//   cprintf("swapIn - passed open pid %d p->sz %d\n",p->pid,p->sz);
  p->pgdir = setupkvm();
  test = allocuvm(p->pgdir,0,p->sz); //changed from KERNBASE
//   cprintf("swapIn - passed allocuvm pid %d returned %d\n",p->pid,test);
//   cprintf("swapFile ip: %d\n",p->swapped_file->ip->size);
  test = loaduvm(p->pgdir,0,p->swapped_file->ip,0,p->sz);
//   cprintf("swapIn - passed loaduvm pid %d returned %d\n",p->pid,test);
  test++;
  int fd;
  for(fd = 0; fd < NOFILE; fd++){
    if(p->ofile[fd] && p->ofile[fd] == p->swapped_file){
     fileclose(p->ofile[fd]);
     p->ofile[fd] = 0;
     break;
    }
  }
  p->swapped_file = 0;
//   cprintf("swapIn - passed fileclose pid %d\n",p->pid);
  test = kernel_unlink(path);
  //test++;
//   cprintf("swapIn - passed kernel_unlink pid %d returned %d\n",p->pid,test);
  acquire(&ptable.lock);
}
开发者ID:yonatana,项目名称:OS,代码行数:37,代码来源:proc.c


示例20: createInternalProcess

void createInternalProcess(const char *name, void (*entrypoint)()){
  
  struct proc *np;

  // Allocate process.
  if((np = allocproc()) == 0)
    cprintf("createInternalProcess error in allocproc\n");

   // Copy process state from p.
  if((np->pgdir = setupkvm(kalloc)) == 0)
   cprintf("createInternalProcess error in setupkvm\n");
 
  memset(np->tf, 0, sizeof(*np->tf));
  np->tf->cs = (SEG_UCODE << 3) | 0;
  np->tf->ds = (SEG_UDATA << 3) | 0;
  np->tf->es = np->tf->ds;
  np->tf->ss = np->tf->ds;
  np->tf->eflags = FL_IF;
   
   
  np->sz = initproc->sz;
  np->parent = initproc;
  *np->tf = *initproc->tf;
  // Clear %eax so that fork returns 0 in the child.
  //np->tf->eax = 0;
  // Set starting point of inswapper
  //np->cwd = idup(initproc->cwd);
  np->cwd = namei("/");
  np->context->eip = (uint)entrypoint;


  
 np->state = RUNNABLE;
 safestrcpy(np->name, name, (strlen(name) + 1));

}
开发者ID:yonatana,项目名称:OS,代码行数:36,代码来源:proc.c



注:本文中的setupkvm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setupterm函数代码示例发布时间:2022-05-30
下一篇:
C++ setup_work_tree函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap