Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6 - Mailing list pgsql-hackers

From Massimo Dal Zotto
Subject Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
Date
Msg-id 199803201059.LAA06405@tango.cs.unitn.it
Whole thread Raw
In response to Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6  (Bruce Momjian <maillist@candle.pha.pa.us>)
Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6  (dg@illustra.com (David Gould))
List pgsql-hackers
>
> >
> > On Mon, 16 Mar 1998, David Gould wrote:
> >
> > > If this will work, I am willing to hack this together tomorrow.
> > > What is the time frame for accepting a patch like this?
> >
> >     Assuming that its *clean* (clean meaning that Bruce fully approves
> > of it, as this is his area of the code...well, one of them
> > *grin*)...tomorrow would be great :)  If Bruce has *any* doubts though, it
> > doesn't go in until after I do the patch I want to do...
>
> David, go for it.  The code is all local in two files, and I think you
> can basically change all the do{test-and-set} while(lock-is-false)
> loops to:
>
>     do{test-and-set} while(lock-is-false && select ())
>
> Pretty easy.  No need to test multiple platforms.  The ones where the
> loop is integrated into the asm(), leave them for later.
>
> --
> Bruce Momjian                          |  830 Blythe Avenue
> maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
>   +  If your life is a hard drive,     |  (610) 353-9879(w)
>   +  Christ can be your backup.        |  (610) 853-3000(h)
>
>
>

I'am against a generic patch using select(). If we have sched_yield() on an
architecture I don't see why dont't use it. Here is the patch for Linux.
It has been tested for two months by 100 users without any problem.
The only thing I would add is a more general configuration test in configure
to include the proper include files.

*** src/include/storage/s_lock.h.orig    Sat Oct 18 22:39:21 1997
--- src/include/storage/s_lock.h    Wed Nov 19 23:11:14 1997
***************
*** 294,300 ****
--- 294,314 ----
   */

  #if defined(NEED_I386_TAS_ASM)
+ #include <unistd.h>
+ #include <sched.h>

+ #ifdef _POSIX_PRIORITY_SCHEDULING
+ #define    S_LOCK(lock)    do \
+                         { \
+                             slock_t        _res; \
+                             do \
+                             { \
+                                 __asm__("xchgb %0,%1": "=q"(_res), \
+                                         "=m"(*lock):"0"(0x1)); \
+                                 if (_res) sched_yield(); \
+                             } while (_res != 0); \
+                         } while (0)
+ #else
  #define    S_LOCK(lock)    do \
                          { \
                              slock_t        _res; \
***************
*** 303,308 ****
--- 317,323 ----
                  __asm__("xchgb %0,%1": "=q"(_res), "=m"(*lock):"0"(0x1)); \
                              } while (_res != 0); \
                          } while (0)
+ #endif

  #define    S_UNLOCK(lock)    (*(lock) = 0)


Massimo Dal Zotto

+----------------------------------------------------------------------+
|  Massimo Dal Zotto                e-mail:  dz@cs.unitn.it            |
|  Via Marconi, 141                 phone:  ++39-461-534251            |
|  38057 Pergine Valsugana (TN)     www:  http://www.cs.unitn.it/~dz/  |
|  Italy                            pgp:  finger dz@tango.cs.unitn.it  |
+----------------------------------------------------------------------+

pgsql-hackers by date:

Previous
From: Mattias Kregert
Date:
Subject: Re: [HACKERS] tables >2GB
Next
From: dg@illustra.com (David Gould)
Date:
Subject: Re: [HACKERS] Buffer overuns with the Electric fence debugging library