Rizin
unix-like reverse engineering framework and cli tools
main.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <uv.h>

Go to the source code of this file.

Functions

void hare (void *arg)
 
void tortoise (void *arg)
 
int main ()
 

Function Documentation

◆ hare()

void hare ( void *  arg)

Definition at line 6 of file main.c.

6  {
7  int tracklen = *((int *) arg);
8  while (tracklen) {
9  tracklen--;
10  sleep(1);
11  fprintf(stderr, "Hare ran another step\n");
12  }
13  fprintf(stderr, "Hare done running!\n");
14 }

Referenced by main().

◆ main()

int main ( void  )

Definition at line 26 of file main.c.

26  {
27  int tracklen = 10;
28  uv_thread_t hare_id;
29  uv_thread_t tortoise_id;
30  uv_thread_create(&hare_id, hare, &tracklen);
31  uv_thread_create(&tortoise_id, tortoise, &tracklen);
32 
33  uv_thread_join(&hare_id);
34  uv_thread_join(&tortoise_id);
35  return 0;
36 }
void tortoise(void *arg)
Definition: main.c:16
void hare(void *arg)
Definition: main.c:6
pthread_t uv_thread_t
Definition: unix.h:136
UV_EXTERN int uv_thread_join(uv_thread_t *tid)
Definition: thread.c:272
UV_EXTERN int uv_thread_create(uv_thread_t *tid, uv_thread_cb entry, void *arg)
Definition: thread.c:210

References hare(), tortoise(), uv_thread_create(), and uv_thread_join().

◆ tortoise()

void tortoise ( void *  arg)

Definition at line 16 of file main.c.

16  {
17  int tracklen = *((int *) arg);
18  while (tracklen) {
19  tracklen--;
20  fprintf(stderr, "Tortoise ran another step\n");
21  sleep(3);
22  }
23  fprintf(stderr, "Tortoise done running!\n");
24 }

Referenced by main().