Skip site navigation (1) Skip section navigation (2)

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

From: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
To: maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Cc: hackers(at)postgresql(dot)org (Pgsql Development)
Subject: Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
Date: 1998-03-20 10:59:01
Message-ID: 199803201059.LAA06405@tango.cs.unitn.it (view raw or flat)
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)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(at)cs(dot)unitn(dot)it            |
|  Via Marconi, 141                 phone:  ++39-461-534251            |
|  38057 Pergine Valsugana (TN)     www:  http://www.cs.unitn.it/~dz/  |
|  Italy                            pgp:  finger dz(at)tango(dot)cs(dot)unitn(dot)it  |
+----------------------------------------------------------------------+

In response to

Responses

pgsql-hackers by date

Next:From: Mattias KregertDate: 1998-03-20 11:59:06
Subject: Re: [HACKERS] tables >2GB
Previous:From: David GouldDate: 1998-03-20 09:20:02
Subject: Re: [HACKERS] Buffer overuns with the Electric fence debugging library

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group