Exemplo n.º 1
0
Arquivo: mm.c Projeto: feng-lei/mario
int dup_mmap(struct task_struct *t)
{
	struct vm_area_struct *vma, *tmp, **p;

	p = &t->mm->mmap;
	*p = NULL;
	for (vma = current->mm->mmap; vma; vma = vma->vm_next) {
		tmp = (struct vm_area_struct *)kmalloc(sizeof(struct vm_area_struct));
		if (!tmp) {
			exit_mmap(t);
			return -ENOMEM;
		}
		*tmp = *vma;
		tmp->vm_mm = t->mm;
		tmp->vm_next = NULL;
		if (tmp->vm_inode)
			iref(tmp->vm_inode);
		/* a shared area? */
		if (tmp->vm_flags & VM_SHARED) {
			tmp->vm_next_share->vm_prev_share = tmp;
			vma->vm_next_share = tmp;
			tmp->vm_prev_share = vma;
		} else {
			tmp->vm_next_share = tmp->vm_prev_share = tmp;
		}
		if (tmp->vm_ops && tmp->vm_ops->open)
			tmp->vm_ops->open(tmp);
		*p = tmp;
		p = &tmp->vm_next;
	}
	return 0;
}
Exemplo n.º 2
0
int
main(int argc, char *argv[])
{
  printf("*******usertests starting*******\n\n");

  printf("=====test file usertests.ran does not exists=====\n");

  if(open("usertests.ran", O_RDONLY) >= 0){
    printf("already ran user tests (file usertests.ran exists) -- recreate certikos_disk.img\n");
    exit();
  }
  printf("=====test file usertests.ran does not exists: ok\n\n");
  close(open("usertests.ran", O_CREATE));

  smallfile();
  bigfile1();
  createtest();

  rmdot();
  fourteen();
  bigfile2();
  subdir();
  linktest();
  unlinkread();
  dirfile();
  iref();
  bigdir(); // slow
  printf("*******end of tests*******\n");
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
  printf(1, "usertests starting\n");

  if(open("usertests.ran", 0) >= 0){
    printf(1, "already ran user tests -- rebuild fs.img\n");
    exit();
  }
  close(open("usertests.ran", O_CREATE));

  createdelete();
  linkunlink();
  concreate();
  fourfiles();
  sharedfd();

  bigargtest();
  bigwrite();
  bigargtest();
  bsstest();
  sbrktest();
  validatetest();

  opentest();
  writetest();
  writetest1();
  createtest();

  openiputtest();
  exitiputtest();
  iputtest();

  mem();
  pipe1();
  preempt();
  exitwait();

  rmdot();
  fourteen();
  bigfile();
  subdir();
  linktest();
  unlinkread();
  dirfile();
  iref();
  forktest();
  bigdir(); // slow
  exectest();

  exit();
}
Exemplo n.º 4
0
Arquivo: mm.c Projeto: feng-lei/mario
/*
 * By the time this function is called, the area struct has been
 * removed from the process mapping list, so it needs to be
 * reinserted if necessary.
 *
 * The 4 main cases are:
 *    Unmapping the whole area
 *    Unmapping from the start of the segment to a point in it
 *    Unmapping from an intermediate point to the end
 *    Unmapping between to intermediate points, making a hole.
 *
 * Case 4 involves the creation of 2 new areas, for each side of
 * the hole.
 */
void unmap_fixup(struct vm_area_struct *vma, 
	unsigned long addr, unsigned long len)
{
	struct vm_area_struct *mpnt;
	unsigned long end = addr + len;

	/* Unmapping the whole area */
	if (addr == vma->vm_start && end == vma->vm_end) {
		if (vma->vm_ops && vma->vm_ops->close)
			vma->vm_ops->close(vma);
		if (vma->vm_inode)
			iput(vma->vm_inode);
		return;
	}
	/* Work out to one of the ends */
	if (end == vma->vm_end) {
		vma->vm_end = addr;
	} else if (addr == vma->vm_start) {
		vma->vm_offset += (end - vma->vm_start);
		vma->vm_start = end;
	} else {
		mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt));
		if (!mpnt)
			return;
		*mpnt = *vma;
		mpnt->vm_offset += (end - vma->vm_start);
		mpnt->vm_start = end;
		if (mpnt->vm_inode)
			iref(mpnt->vm_inode);
		if (mpnt->vm_ops && mpnt->vm_ops->open)
			mpnt->vm_ops->open(mpnt);
		vma->vm_end = addr;	/* Truncate area */
		insert_vm_struct(current->mm, mpnt);
	}
	/* construct whatever mapping is needed */
	mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt));
	if (!mpnt)
		return;
	*mpnt = *vma;
	if (mpnt->vm_ops && mpnt->vm_ops->open)
		mpnt->vm_ops->open(mpnt);
	if (vma->vm_ops && vma->vm_ops->close) {
		vma->vm_end = vma->vm_start;
		vma->vm_ops->close(vma);
	}
	insert_vm_struct(current->mm, mpnt);
}
Exemplo n.º 5
0
kernel::ModelObjectsTemp RigidBodyUmbrella::do_get_inputs() const {
    kernel::Model *m = get_model();
    ModelObjectsTemp ret;
    //reference rb
    ret.push_back(m->get_particle(ref_));
    kernel::ParticleIndexes pref(
        RigidBody(m, ref_).get_member_indexes());
    for (unsigned i=0; i<pref.size(); i++)
        ret.push_back(m->get_particle(pref[i]));
    //target rb
    ret.push_back(m->get_particle(pi_));
    kernel::ParticleIndexes iref(
        RigidBody(m, pi_).get_member_indexes());
    for (unsigned i=0; i<iref.size(); i++)
        ret.push_back(m->get_particle(iref[i]));
    return ret;
}
Exemplo n.º 6
0
Value StandardObject::slot_value(Value arg)
{
  if (!symbolp(arg))
    return signal_type_error(arg, S_symbol);
  Layout * layout = this->layout();
  if (!layout)
    return signal_lisp_error("No layout for instance.");
  if (layout->is_invalid())
    {
      // Update instance.
      layout = update_layout();
    }
  Value value;
  long index = layout->slot_index(arg);
  if (index >= 0)
    {
      value = iref(index);
    }
  else
    {
      // not an instance slot
      Value location = layout->shared_slot_location(arg);
      if (location == NIL)
        {
          // slot-missing
          return current_thread()->execute(the_symbol(S_slot_missing)->function(),
                                           class_of(),
                                           make_value(this),
                                           arg,
                                           S_slot_value);
        }
      value = cdr(location);
    }
  if (value == UNBOUND_VALUE)
    {
      Thread * const thread = current_thread();
      value = thread->execute(the_symbol(S_slot_unbound)->function(),
                              class_of(),
                              make_value(this),
                              arg);
      thread->clear_values();
    }
  return value;
}