Changeset 10c071e in mainline
- Timestamp:
- 2005-12-15T16:57:48Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c68b97
- Parents:
- b4cad8b2
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/include/atomic.h
rb4cad8b2 r10c071e 60 60 } 61 61 62 static inline atomic_t atomic_inc_pre(atomic_t *val)62 static inline count_t atomic_inc_pre(atomic_t *val) 63 63 { 64 atomic_t r; 64 count_t r; 65 65 66 __asm__ volatile ( 66 67 "movl $1, %0\n" 67 68 "lock xaddl %0, %1\n" 68 : "=r" (r), "=m" (val->count)69 : "=r" (r), "=m" (val->count) 69 70 ); 71 70 72 return r; 71 73 } 72 74 73 74 75 static inline atomic_t atomic_dec_pre(atomic_t *val) 75 static inline count_t atomic_dec_pre(atomic_t *val) 76 76 { 77 atomic_t r; 77 count_t r; 78 78 79 __asm__ volatile ( 79 80 "movl $-1, %0\n" 80 81 "lock xaddl %0, %1\n" 81 : "=r" (r), "=m" (*val)82 : "=r" (r), "=m" (*val) 82 83 ); 84 83 85 return r; 84 86 } -
arch/ia64/include/atomic.h
rb4cad8b2 r10c071e 34 34 typedef struct { volatile __u64 count; } atomic_t; 35 35 36 static inline atomic_t atomic_add(atomic_t *val, int imm) 36 /** Atomic addition. 37 * 38 * @param val Atomic value. 39 * @param imm Value to add. 40 * 41 * @return Value after addition. 42 */ 43 static inline count_t atomic_add(atomic_t *val, int imm) 37 44 { 38 atomic_t v;45 count_t v; 39 46 40 41 47 __asm__ volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v), "+m" (val->count) : "i" (imm)); 42 48 … … 57 63 static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); } 58 64 65 static inline count_t atomic_inc_pre(atomic_t *val) { return atomic_add(val, 1); } 66 static inline count_t atomic_dec_pre(atomic_t *val) { return atomic_add(val, -1); } 59 67 60 static inline atomic_t atomic_inc_pre(atomic_t *val) { return atomic_add(val, 1); } 61 static inline atomic_t atomic_dec_pre(atomic_t *val) { return atomic_add(val, -1); } 62 63 64 static inline atomic_t atomic_inc_post(atomic_t *val) { return atomic_add(val, 1) + 1; } 65 static inline atomic_t atomic_dec_post(atomic_t *val) { return atomic_add(val, -1) - 1; } 68 static inline count_t atomic_inc_post(atomic_t *val) { return atomic_add(val, 1) + 1; } 69 static inline count_t atomic_dec_post(atomic_t *val) { return atomic_add(val, -1) - 1; } 66 70 67 71 #endif -
arch/mips32/include/atomic.h
rb4cad8b2 r10c071e 51 51 * @return Value after addition. 52 52 */ 53 static inline atomic_t atomic_add(atomic_t *val, int i)53 static inline count_t atomic_add(atomic_t *val, int i) 54 54 { 55 atomic_t tmp, v;55 count_t tmp, v; 56 56 57 57 __asm__ volatile ( -
arch/sparc64/include/atomic.h
rb4cad8b2 r10c071e 39 39 */ 40 40 41 static inline void atomic_inc(atomic_t *val) { 41 static inline void atomic_inc(atomic_t *val) 42 { 42 43 val->count++; 43 44 } 44 45 45 static inline void atomic_dec(atomic_t *val) { 46 static inline void atomic_dec(atomic_t *val) 47 { 46 48 val->count--; 47 49 } 48 50 51 static inline void atomic_set(atomic_t *val, __u64 i) 52 { 53 val->count = i; 54 } 55 56 static inline __u64 atomic_get(atomic_t *val) 57 { 58 return val->count; 59 } 60 49 61 #endif -
arch/sparc64/include/trap.h
rb4cad8b2 r10c071e 30 30 #define __sparc64_TRAP_H__ 31 31 32 #include <arch/trap_table.h> 33 #include <arch/asm.h> 34 35 /** Switch to in-kernel trap table. */ 36 static inline void trap_switch_trap_table(void) 37 { 38 /* Point TBA to kernel copy of OFW's trap table. */ 39 tba_write((__u64) trap_table); 40 } 41 32 42 extern void trap_init(void); 33 43 -
arch/sparc64/src/mm/tlb.c
rb4cad8b2 r10c071e 36 36 #include <typedefs.h> 37 37 #include <config.h> 38 #include <arch/trap.h> 38 39 39 40 /** Initialize ITLB and DTLB. … … 44 45 * After TLB is initialized, MMU is enabled 45 46 * again. 47 * 48 * Switching MMU off imposes the requirement for 49 * the kernel to run in identity mapped environment. 46 50 */ 47 51 void tlb_arch_init(void) … … 82 86 dtlb_data_in_write(data.value); 83 87 88 /* 89 * Register window traps can occur before MMU is enabled again. 90 * This ensures that any such traps will be handled from 91 * kernel identity mapped trap handler. 92 */ 93 trap_switch_trap_table(); 94 84 95 tlb_invalidate_all(); 85 96 -
arch/sparc64/src/sparc64.c
rb4cad8b2 r10c071e 36 36 { 37 37 ofw_sparc64_console_init(); 38 trap_init(); 38 39 } 39 40 … … 44 45 void arch_pre_smp_init(void) 45 46 { 46 trap_init();47 47 } 48 48 -
arch/sparc64/src/trap.c
rb4cad8b2 r10c071e 32 32 #include <memstr.h> 33 33 34 /** Initialize trap table. */ 34 35 void trap_init(void) 35 36 { … … 38 39 */ 39 40 memcpy((void *) trap_table, (void *) tba_read(), TRAP_TABLE_SIZE); 40 41 /* Point TBA to kernel copy of OFW's trap table. */42 tba_write((__u64) trap_table);43 41 } -
test/synch/rwlock5/test.c
rb4cad8b2 r10c071e 86 86 thread_t *thrd; 87 87 88 items_read = 0;89 items_written = 0;88 atomic_set(&items_read, 0); 89 atomic_set(&items_written, 0); 90 90 91 91 readers = i*READERS; … … 116 116 waitq_wakeup(&can_start, WAKEUP_ALL); 117 117 118 while (items_read != readers || items_written!= writers) {119 printf("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read , writers - items_written, rwlock.readers_in);118 while (items_read.count != readers || items_written.count != writers) { 119 printf("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in); 120 120 thread_usleep(100000); 121 121 } -
test/synch/semaphore1/test.c
rb4cad8b2 r10c071e 90 90 thread_t *thrd; 91 91 92 items_produced = 0;93 items_consumed = 0;92 atomic_set(&items_produced, 0); 93 atomic_set(&items_consumed, 0); 94 94 95 95 consumers = i * CONSUMERS; … … 120 120 waitq_wakeup(&can_start, WAKEUP_ALL); 121 121 122 while (items_consumed != consumers || items_produced!= producers) {123 printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed , producers - items_produced);122 while (items_consumed.count != consumers || items_produced.count != producers) { 123 printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count); 124 124 thread_sleep(1); 125 125 }
Note:
See TracChangeset
for help on using the changeset viewer.