Changeset 2d11a7d8 in mainline for uspace/app/tester/thread/thread1.c
- Timestamp:
- 2009-06-30T15:54:14Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9c40f883
- Parents:
- db24058
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/thread/thread1.c
rdb24058 r2d11a7d8 28 28 */ 29 29 30 #define THREADS 5 30 #define THREADS 20 31 #define DELAY 10 31 32 32 33 #include <atomic.h> … … 43 44 { 44 45 thread_detach(thread_get_id()); 45 46 while (atomic_get(&finish)) { 47 if (!sh_quiet) 48 printf("%llu ", thread_get_id()); 46 47 while (atomic_get(&finish)) 49 48 usleep(100000); 50 }49 51 50 atomic_inc(&threads_finished); 52 51 } 53 52 54 char * test_thread1(bool quiet)53 char *test_thread1(void) 55 54 { 56 unsigned int i , total = 0;57 sh_quiet = quiet;55 unsigned int i; 56 unsigned int total = 0; 58 57 59 58 atomic_set(&finish, 1); 60 59 atomic_set(&threads_finished, 0); 61 62 for (i = 0; i < THREADS; i++) { 60 61 TPRINTF("Creating threads"); 62 for (i = 0; i < THREADS; i++) { 63 63 if (thread_create(threadtest, NULL, "threadtest", NULL) < 0) { 64 if (!quiet) 65 printf("Could not create thread %d\n", i); 64 TPRINTF("\nCould not create thread %u\n", i); 66 65 break; 67 66 } 67 TPRINTF("."); 68 68 total++; 69 69 } 70 70 71 if (!quiet)72 printf("Running threads for 10 seconds...\n");73 sleep(10);71 TPRINTF("\nRunning threads for %u seconds...", DELAY); 72 sleep(DELAY); 73 TPRINTF("\n"); 74 74 75 75 atomic_set(&finish, 0); 76 76 while (atomic_get(&threads_finished) < total) { 77 if (!quiet) 78 printf("Threads left: %d\n", total - atomic_get(&threads_finished)); 77 TPRINTF("Threads left: %u\n", total - atomic_get(&threads_finished)); 79 78 sleep(1); 80 79 }
Note:
See TracChangeset
for help on using the changeset viewer.