From: Fredrik Tolf Date: Fri, 7 Apr 2017 02:02:20 +0000 (+0200) Subject: Merge branch 'master' of git.dolda2000.com:/srv/git/r/utils X-Git-Url: http://dolda2000.com/gitweb/?p=utils.git;a=commitdiff_plain;h=6a4401aa1b7662df406f0751b5f6437cf8325579;hp=bae800dc458b8ad539b6c66f3a9b855fdc9f33e6 Merge branch 'master' of git.dolda2000.com:/srv/git/r/utils --- diff --git a/loadcpu.c b/loadcpu.c new file mode 100644 index 0000000..ca39f7f --- /dev/null +++ b/loadcpu.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +static void *spin(void *uu) +{ + while(1) { + } +} + +int main(int argc, char **argv) +{ + int i, n; + + n = 4; + pthread_t threads[n]; + for(i = 0; i < n; i++) { + if(pthread_create(&threads[i], NULL, spin, NULL)) { + fprintf(stderr, "loadcpu: pthread_create: %s\n", strerror(errno)); + exit(1); + } + } + pthread_join(threads[0], NULL); + return(0); +} + +/* + * Local Variables: + * compile-command: "gcc -g -Wall -o loadcpu loadcpu.c -lpthread" + * End: + */