Changeset 96348adc in mainline for kernel/test/synch/semaphore2.c
- Timestamp:
- 2006-12-12T17:24:58Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e13972
- Parents:
- 34db7fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/synch/semaphore2.c
r34db7fa r96348adc 48 48 static uint32_t seed = 0xdeadbeef; 49 49 50 static uint32_t random(uint32_t max);51 52 static void consumer(void *arg);53 static void failed(void);54 55 50 static uint32_t random(uint32_t max) 56 51 { … … 63 58 return rc; 64 59 } 65 66 60 67 61 static void consumer(void *arg) … … 88 82 } 89 83 90 static void failed(void) 91 { 92 printf("Test failed prematurely.\n"); 93 thread_exit(); 94 } 95 96 void test_semaphore2(void) 84 char * test_semaphore2(void) 97 85 { 98 86 uint32_t i, k; 99 87 100 printf("Semaphore test #2\n");101 102 88 waitq_initialize(&can_start); 103 89 semaphore_initialize(&sem, 5); 104 90 105 91 thread_t *thrd; 106 92 107 for (; ;) { 108 thread_t *thrd; 109 110 k = random(7) + 1; 111 printf("Creating %d consumers\n", k); 112 for (i=0; i<k; i++) { 113 thrd = thread_create(consumer, NULL, TASK, 0, "consumer"); 114 if (thrd) 115 thread_ready(thrd); 116 else 117 failed(); 118 } 119 120 thread_usleep(20000); 121 waitq_wakeup(&can_start, WAKEUP_ALL); 122 } 123 93 k = random(7) + 1; 94 printf("Creating %d consumers\n", k); 95 for (i = 0; i < k; i++) { 96 thrd = thread_create(consumer, NULL, TASK, 0, "consumer"); 97 if (thrd) 98 thread_ready(thrd); 99 else 100 printf("Error creating thread\n"); 101 } 102 103 thread_usleep(20000); 104 waitq_wakeup(&can_start, WAKEUP_ALL); 105 106 return NULL; 124 107 }
Note:
See TracChangeset
for help on using the changeset viewer.