Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6

From: dg(at)illustra(dot)com (David Gould)
To: tih(at)Hamartun(dot)Priv(dot)NO (Tom Ivar Helbekkmo)
Cc: maillist(at)candle(dot)pha(dot)pa(dot)us, scrappy(at)hub(dot)org, dz(at)cs(dot)unitn(dot)it, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
Date: 1998-04-01 19:56:56
Message-ID: 9804011956.AA08443@hawk.illustra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

What do you mean "now with the return values from tas() swapped"? I think
your code looks ok, but just want to be sure we are following the same
grand plan...

> 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
> --

Thanks, this is just what I was looking for. I will fold it in to my changes.
I have gotten a little snowed under with other tasks, but I expect to finalize
my patch next week and will post it.

-dg

David Gould dg(at)illustra(dot)com 510.628.3783 or 510.305.9468
Informix Software (No, really) 300 Lakeside Drive Oakland, CA 94612
- Linux. Not because it is free. Because it is better.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Raines 1998-04-01 20:08:53 Re: Let's talk up 6.3
Previous Message Thomas G. Lockhart 1998-04-01 17:08:35 Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly