Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
922 B

  1. #include <stdio.h>
  2. #include <windows.h>
  3. Spin()
  4. {
  5. int i;
  6. for (i=0;1;i++) {
  7. Sleep(i*7500);
  8. }
  9. }
  10. void
  11. main(void)
  12. {
  13. DWORD ThreadId;
  14. HANDLE Thread;
  15. int i;
  16. int failcount;
  17. failcount = 0;
  18. for (i = 0;; i++) {
  19. Thread = CreateThread(NULL,
  20. 0,
  21. (LPTHREAD_START_ROUTINE)Spin,
  22. NULL,
  23. 0,
  24. &ThreadId
  25. );
  26. if ( (i/50)*50 == i ) {
  27. printf("%d threads created\n", i);
  28. }
  29. if (!Thread) {
  30. failcount++;
  31. printf("%d threads created before %d failure\n", i,failcount);
  32. Sleep(5000);
  33. if ( failcount < 10 ) {
  34. i--;
  35. goto again;
  36. }
  37. break;
  38. }
  39. else {
  40. CloseHandle(Thread);
  41. }
  42. again:;
  43. }
  44. }