示例#1
0
文件: example.c 项目: Oximore/chaos
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;
}
示例#2
0
文件: test59.c 项目: Sciumo/minix
/*===========================================================================*
 *				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);
}
示例#3
0
文件: test59.c 项目: Sciumo/minix
/*===========================================================================*
 *				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);
}
示例#4
0
文件: test59.c 项目: Sciumo/minix
/*===========================================================================*
 *				thread_d				     *
 *===========================================================================*/
static void *thread_d(void *arg) {
  th_d++;
  mthread_exit(NULL); /* Thread wants to stop running */
  return(NULL);
}