Пример #1
0
void waiter2 (void *id)
{
   ft_thread_await (event2);
   ft_thread_cooperate ();
   fprintf (stdout,"exit!\n");
   exit (0);
}
Пример #2
0
void traceinstants(void *a) {
    int i, j = *((int *) a);
    for (i = 0; i < j; ++i) {
        printf("Instant %d\n", i);
        ft_thread_cooperate();
    }
}
Пример #3
0
void traceInstants (void *args)
{
   int i = 0;
   while (1) {
      fprintf(stdout,"\n>>>>>>>>>>> instant %d: ",i++);
      ft_thread_cooperate ();
   }
}
Пример #4
0
void pr (void *text)
{
   int i;
   for (i=0;i<10;i++) {
      fprintf (stdout,"%s",(char*)text);
      ft_thread_cooperate ();
   }
}
Пример #5
0
void trace_instant (void *args)
{
   while (1) {
      fprintf (stdout, "\ninstant %d: ",i);
      i++;
      ft_thread_cooperate ();
   }
}
Пример #6
0
void traceInstants (void *args)
{
   int *pi = (int*) args;
   while (1) {
      (*pi)++;
      ft_thread_cooperate ();
   }
}
Пример #7
0
void h(void *id)
{
   int i;
   for (i=0;i<10;i++){
      fprintf(stdout,"Hello ");
      ft_thread_cooperate();
   }
   exit(0);
}
Пример #8
0
void w(void *id)
{
   int i;
   for (i=0;i<10;i++){
      fprintf(stdout,"World!\n");
      ft_thread_cooperate();
   }
   exit(0);
}
Пример #9
0
/*
 ft_thread_await(evt);
 ft_thread_generate(evt);
*/
void process (void *args)
{
  while (1) {
    if (size(in) > 0) {
       process_value(get(&in), *((int *) args));
    } else {
       ft_thread_await (new_input);
       if (size(in) == 0) ft_thread_cooperate();
    }
  }
}
Пример #10
0
void consume (void *args)
{
  int v = 0;
  while (v < PRODUCED) {
    v = get(out);
    printf(" get value %d \n", v);
    ft_thread_cooperate();
    /* ?????????? */

  }
  exit(0);
}
Пример #11
0
void produce (void *args)
{
  int v = 0;
  
  while (v < PRODUCED) {
    v = (int) (10*((double)rand())/ RAND_MAX);
    put(v,in);
    ft_thread_cooperate();
    /* ?????????? */
    
  }
}
Пример #12
0
void counter (void *args)
{
   int count = 0;
   int i;
   fprintf (stdout, "start counting\n");  
   for (i=0;i<CYCLES;i++) {
      count++;
      if (count%1000 == 0) fprintf (stdout, "*");
      ft_thread_cooperate ();
   }
   fprintf (stdout, "end counting\n");
   exit (0);
}
Пример #13
0
void produce (void *args)
{
  int v = 0;
  while (v < PRODUCED) {
    if (size(file) < FILE_SIZE) {
      put (0,&file);
      PRINT("%d produced\n",0);
      ft_thread_generate (new_elem);
      v++;
    }
    ft_thread_cooperate ();
  }
}
Пример #14
0
void process_value (int v, int n)
{
  int i, j ;
  ft_thread_unlink();
  int t = (int) (10000*((double)rand())/ RAND_MAX);
  usleep(t);
  ft_thread_link(out_sched);
  put(v,&out );
  ft_thread_cooperate();
   ft_thread_unlink();
   ft_thread_link(in_sched);
  
  /* ?????????? */

}
Пример #15
0
void process (void *args)
{
  while (1) {
    if (size(file) > 0){
      int res = get (&file);
      if (res == CYCLES) {
	PRINT("result: %d\n",res);
	processed++;
	if (processed == PRODUCED) exit (0);
      }else{
	process_value(res);
      }
    }else{
      ft_thread_await (new_elem);
      if (size (file) == 0) ft_thread_cooperate ();
    }
  }
}