Exemplo n.º 1
0
void init_rand()
{
//	rand_seed(current_time-s1, current_time, current_time+s3);
//	rand_seed(s1, s2, s3);
	rand_seed(randseed(),randseed(),randseed());
	mudlog("Random number generator initialized.");
}
Exemplo n.º 2
0
/*!
 * \brief Run example for a process.
 */
static void runExample(int who)
{
  Who = who;

  randseed();
  randusleep(1000000);
  
  LOGDIAG1("%s: creating shared memory mutex.", WhoName[Who]);

  if( !OptsNoMutex )
  {
    if( shm_mutex_init(ShmKey, &ShmMutex) < 0 )
    {
      LOGERROR("%s: failed to create mutex.", WhoName[Who]);
    }
  }

  if( createThreads() < 0 )
  {
    return;
  }

  switch( Who )
  {
    case WHO_CHILD:
      sleep(3);
      break;
    case WHO_PARENT:
      sleep(4);
      break;
    default:
      break;
  }

  killThreads();

  if( !OptsNoMutex )
  {
    shm_mutex_destroy(&ShmMutex);
  }
}