| 1 | #include <stdlib.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <errno.h> |
| 5 | #include <pthread.h> |
| 6 | |
| 7 | static void *spin(void *uu) |
| 8 | { |
| 9 | while(1) { |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | int main(int argc, char **argv) |
| 14 | { |
| 15 | int i, n; |
| 16 | |
| 17 | n = 4; |
| 18 | pthread_t threads[n]; |
| 19 | for(i = 0; i < n; i++) { |
| 20 | if(pthread_create(&threads[i], NULL, spin, NULL)) { |
| 21 | fprintf(stderr, "loadcpu: pthread_create: %s\n", strerror(errno)); |
| 22 | exit(1); |
| 23 | } |
| 24 | } |
| 25 | pthread_join(threads[0], NULL); |
| 26 | return(0); |
| 27 | } |
| 28 | |
| 29 | /* |
| 30 | * Local Variables: |
| 31 | * compile-command: "gcc -g -Wall -o loadcpu loadcpu.c -lpthread" |
| 32 | * End: |
| 33 | */ |