Changeset cb01e1e in mainline for kernel/test/synch/rwlock3.c
- Timestamp:
- 2009-04-04T00:26:27Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a85aebd
- Parents:
- 171f9a1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/synch/rwlock3.c
r171f9a1 rcb01e1e 35 35 #include <synch/rwlock.h> 36 36 37 #define THREADS 37 #define THREADS 4 38 38 39 39 static atomic_t thread_count; 40 40 static rwlock_t rwlock; 41 static bool sh_quiet;42 41 43 42 static void reader(void *arg) … … 45 44 thread_detach(THREAD); 46 45 47 if (!sh_quiet) 48 printf("cpu%u, tid %" PRIu64 ": trying to lock rwlock for reading....\n", CPU->id, THREAD->tid); 46 TPRINTF("cpu%u, tid %" PRIu64 ": trying to lock rwlock for reading....\n", CPU->id, THREAD->tid); 49 47 50 48 rwlock_read_lock(&rwlock); 51 49 rwlock_read_unlock(&rwlock); 52 50 53 if (!sh_quiet) { 54 printf("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid); 55 printf("cpu%u, tid %" PRIu64 ": trying to lock rwlock for writing....\n", CPU->id, THREAD->tid); 56 } 57 51 TPRINTF("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid); 52 TPRINTF("cpu%u, tid %" PRIu64 ": trying to lock rwlock for writing....\n", CPU->id, THREAD->tid); 53 58 54 rwlock_write_lock(&rwlock); 59 55 rwlock_write_unlock(&rwlock); 60 56 61 if (!sh_quiet) 62 printf("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid); 57 TPRINTF("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid); 63 58 64 59 atomic_dec(&thread_count); 65 60 } 66 61 67 char * test_rwlock3(bool quiet)62 char *test_rwlock3(void) 68 63 { 69 64 int i; 70 65 thread_t *thrd; 71 sh_quiet = quiet;72 66 73 67 atomic_set(&thread_count, THREADS); … … 80 74 if (thrd) 81 75 thread_ready(thrd); 82 else if (!quiet)83 printf("Could not create reader %d\n", i);76 else 77 TPRINTF("Could not create reader %d\n", i); 84 78 } 85 79 86 80 thread_sleep(1); 87 81 rwlock_write_unlock(&rwlock); 88 82 89 83 while (atomic_get(&thread_count) > 0) { 90 if (!quiet) 91 printf("Threads left: %ld\n", atomic_get(&thread_count)); 84 TPRINTF("Threads left: %ld\n", atomic_get(&thread_count)); 92 85 thread_sleep(1); 93 86 }
Note:
See TracChangeset
for help on using the changeset viewer.