Exemple #1
0
static void * threadfunc(void * arg)
{
  char *name = arg;
  printf("je suis le thread %p, lancé avec l'argument %s\n",
	 mthread_self(), name);
  mthread_yield();
  printf("je suis encore le thread %p, lancé avec l'argument %s\n",
	 mthread_self(), name);
  mthread_exit(arg);
  return NULL;
}
Exemple #2
0
/*===========================================================================*
 *				thread_h				     *
 *===========================================================================*/
static void *thread_h(void *arg) {
  char bigarray[2 * MEG];
  int reply;
  if (mthread_mutex_lock(condition_mutex) != 0) err(14, 1);
  memset(bigarray, '\0', 2 * MEG); /* Actually allocate it */
  th_h++;
  if (mthread_cond_signal(&condition) != 0) err(14, 2);
  if (mthread_mutex_unlock(condition_mutex) != 0) err(14, 3);
  reply = *((int *) arg); 
  mthread_exit((void *) reply);
  return(NULL);
}
Exemple #3
0
/*===========================================================================*
 *				key_b					     *
 *===========================================================================*/
static void *key_b(void *arg)
{
  int i;

  first = 1;
  mthread_yield();

  /* Each new threads gets NULL-initialized values. */
  for (i = 0; i < 5; i++)
	if (mthread_getspecific(key[i]) != NULL) err(18, 1);

  for (i = 0; i < 4; i++)
	if (mthread_setspecific(key[i], (void *) (i + 2)) != 0) err(18, 2);

  mthread_yield();

  /* Deleting a key will not cause a call its destructor at any point. */
  if (mthread_key_delete(key[3]) != 0) err(18, 3);

  mthread_exit(NULL);
  return(NULL);
}
Exemple #4
0
/*===========================================================================*
 *				thread_d				     *
 *===========================================================================*/
static void *thread_d(void *arg) {
  th_d++;
  mthread_exit(NULL); /* Thread wants to stop running */
  return(NULL);
}