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 42... | Line 42... | ||
42 | static void reader(void *arg); |
42 | static void reader(void *arg); |
43 | static void failed(void *arg); |
43 | static void failed(void *arg); |
44 | 44 | ||
45 | void reader(void *arg) |
45 | void reader(void *arg) |
46 | { |
46 | { |
47 | printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", the->cpu->id, the->thread->tid); |
47 | printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid); |
48 | rwlock_read_lock(&rwlock); |
48 | rwlock_read_lock(&rwlock); |
49 | rwlock_read_unlock(&rwlock); |
49 | rwlock_read_unlock(&rwlock); |
50 | printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid); |
50 | printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid); |
51 | 51 | ||
52 | printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", the->cpu->id, the->thread->tid); |
52 | printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid); |
53 | 53 | ||
54 | rwlock_write_lock(&rwlock); |
54 | rwlock_write_lock(&rwlock); |
55 | rwlock_write_unlock(&rwlock); |
55 | rwlock_write_unlock(&rwlock); |
56 | printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid); |
56 | printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid); |
57 | 57 | ||
58 | printf("Test passed.\n"); |
58 | printf("Test passed.\n"); |
59 | 59 | ||
60 | } |
60 | } |
61 | 61 | ||
Line 75... | Line 75... | ||
75 | rwlock_initialize(&rwlock); |
75 | rwlock_initialize(&rwlock); |
76 | 76 | ||
77 | rwlock_write_lock(&rwlock); |
77 | rwlock_write_lock(&rwlock); |
78 | 78 | ||
79 | for (i=0; i<4; i++) { |
79 | for (i=0; i<4; i++) { |
80 | thrd = thread_create(reader, NULL, the->task, 0); |
80 | thrd = thread_create(reader, NULL, TASK, 0); |
81 | if (thrd) |
81 | if (thrd) |
82 | thread_ready(thrd); |
82 | thread_ready(thrd); |
83 | else |
83 | else |
84 | failed(); |
84 | failed(); |
85 | } |
85 | } |