Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
От | Tom Ivar Helbekkmo |
---|---|
Тема | Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6 |
Дата | |
Msg-id | 86ra3iblqv.fsf@barsoom.Hamartun.Priv.NO обсуждение исходный текст |
Ответ на | Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6 (dg@illustra.com (David Gould)) |
Ответы |
Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
|
Список | pgsql-hackers |
David Gould wrote: > Seriously, if you want to, please create a function to emulate the following: > > /* > * tas(lock) > * > * Access to platform specific test_and_set functionality. Given pointer to > * lock attempts to acquire the lock atomically. > * > * Returns 0 for success, nonzero for failure. > */ > typedef slock_t unsigned char; /* or whatever works on the platform */ > > int tas(slock_t *lock) > { > slock_t tmp; > > /* atomic, interlocked */ > tmp = *lock; > *lock = -1; /* any nonzero will do here */ > > return (tmp != 0); > } > > Given this, I can fold the VAX right into the grand scheme, just like a > normal computer (;-)). Hmpf! The true worth of a computer is a function of its weight! :-) Sorry this took a while, but anyway, this should do it for the VAX (in fact, it's more or less the version of the code that I figured I'd use until Bruce asked me to bum it down maximally for performance, only now with the return values from tas() swapped). I include the macros that would fit the current (6.3) locking scheme: typedef unsigned char slock_t; int tas(slock_t *lock) { register ret; asm(" movl $1, r0 bbssi $0,(%1),1f clrl r0 1: movl r0,%0" : "=r"(ret) /* return value, in register */ : "r"(lock) /* argument, 'lock pointer', in register */ : "r0"); /* inline code uses this register */ return ret; } #define S_LOCK(addr) do { while (tas(addr)) ; } while (0) #define S_UNLOCK(addr) (*(addr) = 0) #define S_INIT_LOCK(addr) (*(addr) = 0) -tih -- Popularity is the hallmark of mediocrity. --Niles Crane, "Frasier"
В списке pgsql-hackers по дате отправления: