HIDDEN void
tdep_init (void)
{
  intrmask_t saved_mask;

  sigfillset (&unwi_full_mask);

  lock_acquire (&arm_lock, saved_mask);
  {
    if (tdep_init_done)
      /* another thread else beat us to it... */
      goto out;

    /* read ARM unwind method setting */
    const char* str = getenv ("UNW_ARM_UNWIND_METHOD");
    if (str)
      {
        unwi_unwind_method = atoi (str);
      }

    mi_init ();

    dwarf_init ();

#ifndef UNW_REMOTE_ONLY
    arm_local_addr_space_init ();
#endif
    tdep_init_done = 1;	/* signal that we're initialized... */
  }
 out:
  lock_release (&arm_lock, saved_mask);
}
Example #2
0
HIDDEN void
tdep_init (void)
{
  intrmask_t saved_mask;

  sigfillset (&unwi_full_mask);

  lock_acquire (&hppa_lock, saved_mask);
  {
    if (!tdep_needs_initialization)
      /* another thread else beat us to it... */
      goto out;

    mi_init ();

    dwarf_init ();

#ifndef UNW_REMOTE_ONLY
    hppa_local_addr_space_init ();
#endif
    tdep_needs_initialization = 0;	/* signal that we're initialized... */
  }
 out:
  lock_release (&hppa_lock, saved_mask);
}
Example #3
0
/* Initialise the workspace; returns nonzero for success, zero otherwise */
unsigned wsinit() {
	_gws.m = malloc(sizeof(*(_gws.m))*meanings);
	_gws.s = malloc(sizeof(*(_gws.s))*signals);
	_gws.mi = mi_init();
	_gws.si = si_init();
	return (_gws.m && _gws.s && _gws.mi && _gws.si);
}
Example #4
0
int main(int argc, char **argv){
	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);
	
	mi_init(argc, argv);
	
	printf("enter barrier\n");
	mi_barrier();
	printf("exit barrier\n");

	int i, j;
	int *result = (int *)mi_alloc(sizeof(int));
	printf("enter barrier\n");
	mi_barrier();
	printf("exit barrier\n");

	for(i = 0; i < 3000; i++){	
		printf("before lock\n");
		mi_lock(0);
		printf("after lock\n");
		*result = *result + 1;
		printf("before unlock\n");
		mi_unlock(0);
		printf("after unlock\n");
	}
	
	printf("enter barrier\n");
	mi_barrier();
	printf("exit barrier\n");
	printf("result = %d\n", *result);
	mi_barrier();
	showDataStructures();
}
Example #5
0
HIDDEN void
tdep_init (void)
{
  intrmask_t saved_mask;

  sigfillset (&unwi_full_mask);

  sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
  mutex_lock (&arm_lock);
  {
    if (!tdep_needs_initialization)
      /* another thread else beat us to it... */
      goto out;

    mi_init ();

    dwarf_init ();

#ifndef UNW_REMOTE_ONLY
    arm_local_addr_space_init ();
#endif
    tdep_needs_initialization = 0;	/* signal that we're initialized... */
  }
 out:
  mutex_unlock (&arm_lock);
  sigprocmask (SIG_SETMASK, &saved_mask, NULL);
}
Example #6
0
HIDDEN void
tdep_init (void)
{
  intrmask_t saved_mask;

  Debug(1, "called\n");

  sigfillset (&unwi_full_mask);

  lock_acquire (&x86_64_lock, saved_mask);
  {
    if (tdep_init_done)
      /* another thread else beat us to it... */
      goto out;

    mi_init ();

    dwarf_init ();

    tdep_init_mem_validate ();

    x86_64_local_addr_space_init ();

    tdep_init_done = 1; /* signal that we're initialized... */
  }
 out:
  lock_release (&x86_64_lock, saved_mask);

  Debug(1, "done\n");
}
Example #7
0
HIDDEN void
tdep_init (void)
{
  intrmask_t saved_mask;

  sigfillset (&unwi_full_mask);

  lock_acquire (&x86_64_lock, saved_mask);
  {
    if (tdep_init_done)
      /* another thread else beat us to it... */
      goto out;

    mi_init ();

    dwarf_init ();

    tdep_init_mem_validate ();

#ifndef UNW_REMOTE_ONLY
    x86_64_local_addr_space_init ();
#endif
    tdep_init_done = 1; /* signal that we're initialized... */
  }
 out:
  lock_release (&x86_64_lock, saved_mask);
}
Example #8
0
int main(int argc, char **argv){
	//myhostid = 0;
	//strcpy(hosts[0].address, "192.168.48.42");
	//strcpy(hosts[0].username, "yating");
	//strcpy(hosts[1].address, "192.168.48.40");
	//strcpy(hosts[1].username, "zeyu");
	//hostnum = 2;


	//initnet();
	//initsyn();
	mi_init(argc, argv);
	
	printf("enter barrier\n");
	mi_barrier();
	printf("exit barrier\n");

	int i, j, result;
	result = 0;
	printf("grasp lock 0\n");
	mi_lock(0);
	printf("grasp lock 0 successfully\n");
	for(i = 0; i < 10000; i++){
		for(j = 0; j < 100; j++){
			result++;
		}
	}
	printf("free lock 0\n");
	mi_lock(0);
	printf("free lock 0 successfully\n");
	
	printf("grasp lock 1\n");
	mi_lock(1);
	printf("grasp lock 1 successfully\n");

	printf("enter barrier\n");
	mi_barrier();
	printf("exit barrier\n");
	printf("result = %d\n",result);
}
Example #9
0
HIDDEN void
tdep_init (void)
{
  lock_init (&x86_64_lock, "tdep_init");

  lock_acquire (&x86_64_lock);
  {
    if (tdep_init_done)
      /* another thread else beat us to it... */
      goto out;

  
    mi_init ();
    dwarf_init ();
    tdep_init_mem_validate ();
    x86_64_local_addr_space_init ();

    tdep_init_done = 1;	/* signal that we're initialized... */
  }
 out:
  lock_release (&x86_64_lock);
}
Example #10
0
File: mm.c Project: ZeyuMi/MiDSM
int main(int argc, char **argv)
{
	int x, y, z, p, magic;
	int error;
	int (*local)[N] = (int (*)[N])malloc(N * N * sizeof(int));

	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);
	mi_init(argc, argv);

	mi_barrier();

	a = (int (*)[N])mi_alloc(N * N * sizeof(int));
	b = (int (*)[N])mi_alloc(N * N * sizeof(int));
	c = (int (*)[N])mi_alloc(N * N * sizeof(int));

	printf("Memory Allocation Done\n");

	printf("starting barrier\n");
	mi_barrier();
	printf("exiting barrier\n"); 

	printf("Initializing matrices ....................\n");
	mi_lock(0);
	seqinit();
	mi_unlock(0);
	printf("Initializing matrices done!\n");

	printf("starting barrier 2\n");
	mi_barrier();
	printf("exiting barrier 2\n");

	magic = N / hostnum;

	for (x = myhostid * magic; x < (myhostid + 1) * magic; x++){
		printf("x = %d\n",x);
		for (y = 0; y < N; y++)
			for (z = 0; z < N; z++)
				local[y][z] += (a[x][y] * b[x][z]);
		printf("x = %d done\n",x);
	}

	printf("starting barrier 3\n");
	mi_barrier();
	printf("exiting barrier 3\n");

	for (x = 0; x < hostnum; x++) 
	{
		p = (myhostid + x) % hostnum;
		printf("lock %d\n", p);
		mi_lock(p);
		printf("lock %d done\n", p);
		for (y = p * magic; y < (p + 1) * magic; y++)
		{  
			for (z = 0; z < N; z++)
			{  if (x == 0) c[y][z] = local[y][z];
				else c[y][z] += local[y][z];
			}
		}
		printf("unlock %d\n", p);
		mi_unlock(p);
		printf("unlock %d done\n", p);
		if (x == 0) mi_barrier();
	}
//	mi_lock(0);
//	for(x = 0; x < N; x++){
//		for(y = 0; y < N; y++){
//			c[x][y] += local[x][y];
//		}
//	}
//	mi_unlock(0);

	mi_barrier();


	if (myhostid == 0)
	{
		error = 0;
		for (x = 0; x < hostnum; x++)
		{
			mi_lock(x);
			for (y = x * magic; y < (x + 1) * magic; y++)
			{
				for (z = 0; z < N; z++)
				{
					if (c[y][z] != N) 
					{  error = 1;
						printf("ERROR: y = %d, z = %d, c = %d\n", y, z, c[y][z]);
					}
				}
			}
			mi_unlock(x);
		}
		if (error == 1) 
			printf("NOTE: There is some error in the program!\n");
	}
	printf("program will exit\n");
	mi_barrier();
} 
Example #11
0
HIDDEN void
tdep_init (void)
{
  uint8_t f1_bytes[16] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  uint8_t nat_val_bytes[16] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  uint8_t int_val_bytes[16] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3e,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  intrmask_t saved_mask;
  uint8_t *lep, *bep;
  long i;

  sigfillset (&unwi_full_mask);

  sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
  mutex_lock (&unw.lock);
  {
    if (!tdep_needs_initialization)
      /* another thread else beat us to it... */
      goto out;

    mi_init ();

    mempool_init (&unw.reg_state_pool, sizeof (struct ia64_reg_state), 0);
    mempool_init (&unw.labeled_state_pool,
		  sizeof (struct ia64_labeled_state), 0);

    unw.read_only.r0 = 0;
    unw.read_only.f0.raw.bits[0] = 0;
    unw.read_only.f0.raw.bits[1] = 0;

    lep = (uint8_t *) &unw.read_only.f1_le + 16;
    bep = (uint8_t *) &unw.read_only.f1_be;
    for (i = 0; i < 16; ++i)
      {
	*--lep = f1_bytes[i];
	*bep++ = f1_bytes[i];
      }

    lep = (uint8_t *) &unw.nat_val_le + 16;
    bep = (uint8_t *) &unw.nat_val_be;
    for (i = 0; i < 16; ++i)
      {
	*--lep = nat_val_bytes[i];
	*bep++ = nat_val_bytes[i];
      }

    lep = (uint8_t *) &unw.int_val_le + 16;
    bep = (uint8_t *) &unw.int_val_be;
    for (i = 0; i < 16; ++i)
      {
	*--lep = int_val_bytes[i];
	*bep++ = int_val_bytes[i];
      }

    assert (8*sizeof(unw_hash_index_t) >= IA64_LOG_UNW_HASH_SIZE);

#ifndef UNW_REMOTE_ONLY
    ia64_local_addr_space_init ();
#endif
    tdep_needs_initialization = 0;	/* signal that we're initialized... */
  }
 out:
  mutex_unlock (&unw.lock);
  sigprocmask (SIG_SETMASK, &saved_mask, NULL);
}