MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / libc_ex3

Function libc_ex3

examples/libc/ex3.c:32–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30volatile int started;
31
32int libc_ex3()
33{
34 int i;
35 int pid;
36
37 /* create a number to search for */
38 pid = getpid();
39 printf("Searching for the number = %d...\n", pid);
40
41 /* Initialize the mutex lock */
42 pthread_mutex_init(&lock, NULL);
43
44 /* Create the searching threads */
45 for (started=0; started<NUM_THREADS; started++)
46 pthread_create(&threads[started], NULL, search, (void *)pid);
47
48 /* Wait for (join) all the searching threads */
49 for (i=0; i<NUM_THREADS; i++)
50 pthread_join(threads[i], NULL);
51
52 printf("It took %d tries to find the number.\n", tries);
53
54 /* Exit the program */
55 return 0;
56}
57#include <finsh.h>
58FINSH_FUNCTION_EXPORT(libc_ex3, example 5 for libc);
59

Callers

nothing calls this directly

Calls 4

pthread_mutex_initFunction · 0.85
pthread_createFunction · 0.85
pthread_joinFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected