Ejemplo n.º 1
0
int page_store(struct proc *p, const char *src, int addr)
{
	int global_addr;
	
	if (p == NULL) {
		fprintf(stderr, "page_store: invalid process\n");
		return -1;
	}
	global_addr = get_global_address(p, addr);
	if (global_addr < 0) {
		fprintf(stderr, "page_store: invalid address\n");
		return -1;
	}
	/* secondary storage maps directly to the address space, so just copy it */
	memcpy(&page_mem[global_addr*4], src, 4);
	return 0;
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*/
static void
create_dag_callback(void *ptr)
{
  const uip_ipaddr_t *root, *ipaddr;

  root = dag_root();
  ipaddr = get_global_address();

  if(root == NULL || uip_ipaddr_cmp(root, ipaddr)) {
    /* The RPL network we are joining is one that we created, so we
       become root. */
    if(to_become_root) {
      rpl_dag_root_init_dag_immediately();
      to_become_root = 0;
    }
  } else {
    rpl_dag_t *dag;

    dag = rpl_get_any_dag();
#if DEBUG
    printf("Found a network we did not create\n");
    printf("version %d grounded %d preference %d used %d joined %d rank %d\n",
           dag->version, dag->grounded,
           dag->preference, dag->used,
           dag->joined, dag->rank);
#endif /* DEBUG */

    /* We found a RPL network that we did not create so we just join
       it without becoming root. But if the network has an infinite
       rank, we assume the network has broken, and we become the new
       root of the network. */

    if(dag->rank == INFINITE_RANK) {
      if(to_become_root) {
        rpl_dag_root_init_dag_immediately();
        to_become_root = 0;
      }
    }

    /* Try again after the grace period */
    ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL);
  }
}