Subversion Repositories Kolibri OS

Rev

Rev 854 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 854 Rev 886
Line 34... Line 34...
34
	volatile long count;
34
	volatile long count;
35
} atomic_t;
35
} atomic_t;
Line 36... Line 36...
36
 
36
 
37
static inline void atomic_inc(atomic_t *val) {
37
static inline void atomic_inc(atomic_t *val) {
38
#ifdef USE_SMP
38
#ifdef USE_SMP
39
  asm volatile ("lock inc %0\n" : "+m" (val->count));
39
  asm volatile ("lock incl %0\n" : "+m" (val->count));
40
#else
40
#else
41
  asm volatile ("inc %0\n" : "+m" (val->count));
41
  asm volatile ("incl %0\n" : "+m" (val->count));
42
#endif /* USE_SMP */
42
#endif /* USE_SMP */
Line 43... Line 43...
43
}
43
}
44
 
44
 
45
static inline void atomic_dec(atomic_t *val) {
45
static inline void atomic_dec(atomic_t *val) {
46
#ifdef USE_SMP
46
#ifdef USE_SMP
47
  asm volatile ("lock dec %0\n" : "+m" (val->count));
47
  asm volatile ("lock decl %0\n" : "+m" (val->count));
48
#else
48
#else
49
  asm volatile ("dec %0\n" : "+m" (val->count));
49
  asm volatile ("decl %0\n" : "+m" (val->count));
Line 50... Line 50...
50
#endif /* USE_SMP */
50
#endif /* USE_SMP */
51
}
51
}
Line 96... Line 96...
96
static inline void atomic_lock_arch(atomic_t *val)
96
static inline void atomic_lock_arch(atomic_t *val)
97
{
97
{
98
  u32_t tmp;
98
  u32_t tmp;
Line 99... Line 99...
99
 
99
 
-
 
100
//  preemption_disable();
100
//  preemption_disable();
101
 
101
	asm volatile (
102
    asm volatile (
102
    "0:\n"
103
		"0:\n"
103
    "pause\n\t" /* Pentium 4's HT love this instruction */
104
		"pause\n" /* Pentium 4's HT love this instruction */
104
    "mov %1, [%0]\n\t"
105
		"mov %0, %1\n"
105
    "test %1, %1\n\t"
106
		"testl %1, %1\n"
106
    "jnz 0b\n\t"       /* lightweight looping on locked spinlock */
107
		"jnz 0b\n"       /* lightweight looping on locked spinlock */
107
 
108
 
108
    "inc %1\n\t"      /* now use the atomic operation */
109
		"incl %1\n"      /* now use the atomic operation */
109
    "xchg [%0], %1\n\t"
110
		"xchgl %0, %1\n"
110
    "test %1, %1\n\t"
111
		"testl %1, %1\n"
111
    "jnz 0b\n\t"
112
		"jnz 0b\n"
112
    : "+m" (val->count), "=r"(tmp)
113
    : "+m" (val->count), "=&r"(tmp)
113
	);
-
 
114
	/*
-
 
115
	 * Prevent critical section code from bleeding out this way up.
-
 
116
	 */
114
  );
117
 // CS_ENTER_BARRIER();
115
 // CS_ENTER_BARRIER();
Line 118... Line 116...
118
}
116
}
119
 
117