Re: [HACKERS] Compiling 6.4 on NetBSD-current/pc532

Поиск
Список
Период
Сортировка
От dg@informix.com (David Gould)
Тема Re: [HACKERS] Compiling 6.4 on NetBSD-current/pc532
Дата
Msg-id 9809180627.AA18052@hawk.oak.informix.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Compiling 6.4 on NetBSD-current/pc532  (Bruce Momjian <maillist@candle.pha.pa.us>)
Ответы Re: [HACKERS] Compiling 6.4 on NetBSD-current/pc532  (Bruce Momjian <maillist@candle.pha.pa.us>)
Re: [HACKERS] Compiling 6.4 on NetBSD-current/pc532  (Jon Buller <jonb@metronet.com>)
Список pgsql-hackers
>
> Applied.
>
> > OK,
> >
> > I have a current version of PostgreSQL running on my pc532 now.
> > (It's a NS32K based machine.  Somewhat of an antique really...)
> >
> >
> > *** /usr/local/pgsql/src/include/storage/s_lock.h    Fri Sep 11 19:00:55 1998
> > --- s_lock.h    Sat Sep 12 00:27:51 1998
> > ***************
> > *** 213,219 ****
> >   #endif     /* NEED_I386_TAS_ASM */
> >
> >
> > ! /* NS32K code is in s_lock.c */
> >
> >   #endif     /* defined(__GNUC__) */
> >
> > --- 213,234 ----
> >   #endif     /* NEED_I386_TAS_ASM */
> >
> >
> > !
> > ! #if defined(NEED_NS32K_TAS_ASM)
> > !
> > ! #define S_LOCK(lock)                \
> > ! {                        \
> > !     slock_t res = 1;                \
> > !     while (res) {                \
> > !       __asm__("movqd 0, r0");            \
> > !       __asm__("sbitd r0, %0" : "=m"(*lock));    \
> > !       __asm__("sprb us, %0" : "=r" (res));    \
> > !       res = ((res >> 5) & 1);            \
> > !     }                        \
> > ! }
> > !
> > ! #endif     /* NEED_NS32K_TAS_ASM */
> > !
> >
> >   #endif     /* defined(__GNUC__) */
> >
> > *** /usr/local/pgsql/src/backend/storage/buffer/s_lock.c    Thu Sep 10 23:08:00 1998
> > --- s_lock.c    Sat Sep 12 00:23:04 1998
> > ***************
> > *** 118,134 ****
> >   #endif     /* PPC */
> >
> >
> > - #if defined(__ns32k__)
> > - int
> > - tas(volatile slock_t *lock)
> > - {
> > -   int res;
> > -   __asm__("sbitb 0, %0" : "=m"(*lock));
> > -   __asm__("sprb us, %0" : "=r"(res));
> > -   res = (res >> 5) & 1;
> > -   return res;
> > - }
> > - #endif
> >
> >   #else                            /* defined(__GNUC__) */
> >   /***************************************************************************
> > --- 118,123 ----
> >
> >
> > BTW, does the spinlock code need a TAS function so it can spin for
> > a while and then declare itself stuck, or does a second process/thread
> > take care of that.  It would be simpler for the NS32K to just make
> > the whole lock function be 2 lines of inline assembler, but that
> > would contain an infinite loop if the lock was stuck...
> >
> > Jon Buller  <jonb@metronet.com>

I wish I had noticed this before Bruce applied it.

The TAS function is needed so that stuck spinlocks can be recovered from.
Also, it enables the pseudo random back off which helps performance when
there are many backends.

In any case, this patch does not "follow the one true path" that I tried
to outline in s_lock.c and s_lock.h. In fact it is exactly backwards.

Basically the preferred way is:

 - in s_lock.h do nothing, the defaults should take care of you.

  -in s_lock.c define a TAS function that sets the spinlock and returns the
   previous state of the lock.

I see from your asm()s that you are using gcc. In this case, your TAS function
should be called tas(), and should be defined inside the __GNUC__ section.

-dg

David Gould            dg@informix.com           510.628.3783 or 510.305.9468
Informix Software  (No, really)         300 Lakeside Drive  Oakland, CA 94612
 - If simplicity worked, the world would be overrun with insects. -

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Compiling 6.4 on NetBSD-current/pc532
Следующее
От: Michael Meskes
Дата:
Сообщение: ecpg docs