diff options
author | Angelo Marletta <angelo.marletta@gmail.com> | 2012-06-01 02:00:57 +0100 |
---|---|---|
committer | Angelo Marletta <angelo.marletta@gmail.com> | 2012-06-01 02:00:57 +0100 |
commit | fa8c64b0e28125362c2db8897d92073409c0277a (patch) | |
tree | 4188eafd3cdd8b449e2ea4a098f1f17cf06e7662 /tests/busy.c | |
parent | b81215b9fbcb0e27d7bb9b4abaa8179ff11b5bfb (diff) | |
download | cpulimit-fa8c64b0e28125362c2db8897d92073409c0277a.tar.gz |
added directory for tests
Diffstat (limited to 'tests/busy.c')
-rw-r--r-- | tests/busy.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/busy.c b/tests/busy.c new file mode 100644 index 0000000..bb2e2ed --- /dev/null +++ b/tests/busy.c @@ -0,0 +1,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; 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); + } + } + printf("Press ENTER to exit..."); + getchar(); + return 0; +}
\ No newline at end of file |