aboutsummaryrefslogtreecommitdiffstats
path: root/tests/busy.c
blob: b3afb7cd853b5d5f881f5faf63fff356f8f33fe8 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>

void *loop()
{
	while(1);
}

int main(int argc, char **argv) {

	int i = 0;
	int num_threads = 1;
	if (argc == 2) num_threads = atoi(argv[1]);
	for (i=0; i<num_threads-1; i++)
	{
		pthread_t thread;
		int ret;
		if ((ret = pthread_create(&thread, NULL, loop, NULL)) != 0)
		{
			printf("pthread_create() failed. Error code %d\n", ret);
			exit(1);
		}
	}
	loop();
	return 0;
}

Un proyecto texto-plano.xyz