Changeset e9d2905 in mainline
- Timestamp:
- 2018-09-07T15:50:02Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 036e97c
- Parents:
- 077842c
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/atomic.h
r077842c re9d2905 42 42 typedef size_t atomic_count_t; 43 43 typedef ssize_t atomic_signed_t; 44 45 typedef struct { 46 volatile atomic_size_t count; 47 } atomic_t; 44 typedef atomic_size_t atomic_t; 48 45 49 46 static inline void atomic_set(atomic_t *val, atomic_count_t i) 50 47 { 51 atomic_store( &val->count, i);48 atomic_store(val, i); 52 49 } 53 50 54 51 static inline atomic_count_t atomic_get(atomic_t *val) 55 52 { 56 return atomic_load( &val->count);53 return atomic_load(val); 57 54 } 58 55 59 56 static inline size_t atomic_predec(atomic_t *val) 60 57 { 61 return atomic_fetch_sub( &val->count, 1) - 1;58 return atomic_fetch_sub(val, 1) - 1; 62 59 } 63 60 64 61 static inline size_t atomic_preinc(atomic_t *val) 65 62 { 66 return atomic_fetch_add( &val->count, 1) + 1;63 return atomic_fetch_add(val, 1) + 1; 67 64 } 68 65 69 66 static inline size_t atomic_postdec(atomic_t *val) 70 67 { 71 return atomic_fetch_sub( &val->count, 1);68 return atomic_fetch_sub(val, 1); 72 69 } 73 70 74 71 static inline size_t atomic_postinc(atomic_t *val) 75 72 { 76 return atomic_fetch_add( &val->count, 1);73 return atomic_fetch_add(val, 1); 77 74 } 78 75 79 76 static inline void atomic_dec(atomic_t *val) 80 77 { 81 atomic_fetch_sub( &val->count, 1);78 atomic_fetch_sub(val, 1); 82 79 } 83 80 84 81 static inline void atomic_inc(atomic_t *val) 85 82 { 86 atomic_fetch_add( &val->count, 1);83 atomic_fetch_add(val, 1); 87 84 } 88 85 … … 92 89 static inline bool test_and_set(atomic_t *val) 93 90 { 94 return atomic_exchange( &val->count, 1);91 return atomic_exchange(val, 1); 95 92 } 96 93 -
kernel/test/synch/semaphore1.c
r077842c re9d2905 115 115 waitq_wakeup(&can_start, WAKEUP_ALL); 116 116 117 while ((items_consumed .count != consumers) || (items_produced.count!= producers)) {117 while ((items_consumed != consumers) || (items_produced != producers)) { 118 118 TPRINTF("%zu consumers remaining, %zu producers remaining\n", 119 consumers - items_consumed .count, producers - items_produced.count);119 consumers - items_consumed, producers - items_produced); 120 120 thread_sleep(1); 121 121 }
Note:
See TracChangeset
for help on using the changeset viewer.