File: thread-main.c

package info (click to toggle)
kcov 43%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,600 kB
  • sloc: cpp: 12,617; ansic: 2,379; python: 2,001; sh: 333; makefile: 133; javascript: 65; xml: 7; asm: 4
file content (40 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <semaphore.h>
#include <stdlib.h>

void *thread_cb(void *ptr)
{
	printf("Thread Created\r\n");

	return NULL;
}

void* real_thread_create()
{
	pthread_t thr;
	int i;

	// 10 seconds
	for (i = 0; i < 1000; i++) {
		pthread_create(&thr, NULL, thread_cb, NULL);
		usleep(10 * 1000); // 10 ms
	}

	return NULL;
}


int main(int argc, const char *argv[])
{
	pthread_t tid;
	void *retv;

	pthread_create(&tid, NULL, real_thread_create, NULL);

	pthread_join(tid, &retv);

	return 0;
}