Rev 1 | Rev 19 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 15 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | { |
67 | { |
68 | int rc, to; |
68 | int rc, to; |
69 | waitq_sleep(&can_start); |
69 | waitq_sleep(&can_start); |
70 | 70 | ||
71 | to = random(20000); |
71 | to = random(20000); |
72 | printf("cpu%d, tid %d down+ (%d)\n", the->cpu->id, the->thread->tid, to); |
72 | printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to); |
73 | rc = semaphore_down_timeout(&sem, to); |
73 | rc = semaphore_down_timeout(&sem, to); |
74 | if (SYNCH_FAILED(rc)) { |
74 | if (SYNCH_FAILED(rc)) { |
75 | printf("cpu%d, tid %d down!\n", the->cpu->id, the->thread->tid); |
75 | printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid); |
76 | return; |
76 | return; |
77 | } |
77 | } |
78 | 78 | ||
79 | printf("cpu%d, tid %d down=\n", the->cpu->id, the->thread->tid); |
79 | printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid); |
80 | thread_usleep(random(30000)); |
80 | thread_usleep(random(30000)); |
81 | 81 | ||
82 | semaphore_up(&sem); |
82 | semaphore_up(&sem); |
83 | printf("cpu%d, tid %d up\n", the->cpu->id, the->thread->tid); |
83 | printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid); |
84 | } |
84 | } |
85 | 85 | ||
86 | void failed(void) |
86 | void failed(void) |
87 | { |
87 | { |
88 | printf("Test failed prematurely.\n"); |
88 | printf("Test failed prematurely.\n"); |
Line 105... | Line 105... | ||
105 | thread_t *thrd; |
105 | thread_t *thrd; |
106 | 106 | ||
107 | k = random(7) + 1; |
107 | k = random(7) + 1; |
108 | printf("Creating %d consumers\n", k); |
108 | printf("Creating %d consumers\n", k); |
109 | for (i=0; i<k; i++) { |
109 | for (i=0; i<k; i++) { |
110 | thrd = thread_create(consumer, NULL, the->task, 0); |
110 | thrd = thread_create(consumer, NULL, TASK, 0); |
111 | if (thrd) |
111 | if (thrd) |
112 | thread_ready(thrd); |
112 | thread_ready(thrd); |
113 | else |
113 | else |
114 | failed(); |
114 | failed(); |
115 | } |
115 | } |