spacepaste

  1.  
  2. #include <stdio.h>
  3. #include <assert.h>
  4. #include <unistd.h>
  5. #include <pthread.h>
  6. volatile int foo;
  7. static void *loopy(void *arg)
  8. {
  9. volatile int foo2;
  10. for (long i = 0; i < 125000000; i++)
  11. {
  12. foo++;
  13. for (int k = 0; k < 4; k++)
  14. foo2++;
  15. }
  16. printf("done\n");
  17. return 0;
  18. }
  19. int main(void)
  20. {
  21. pthread_t th;
  22. for (int j = 0; j < 2; j++)
  23. pthread_create(&th, NULL, loopy, NULL);
  24. sleep(999);
  25. }
  26.