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

Re: Assuming that TAS() will succeed the first time is verboten

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Assuming that TAS() will succeed the first time is verboten
Date: 2000-12-28 22:12:22
Message-ID: 6232.978041542@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
ncm(at)zembu(dot)com (Nathan Myers) writes:
> I wonder about the advisability of using spinlocks in user-level code 
> which might be swapped out any time.

The reason we use spinlocks is that we expect the lock to succeed (not
block) the majority of the time, and we want the code to fall through
as quickly as possible in that case.  In particular we do *not* want to
expend a kernel call when we are able to acquire the lock immediately.
It's not a true "spin" lock because we don't sit in a tight loop when
we do have to wait for the lock --- we use select() to delay for a small
interval before trying again.  See src/backend/storage/buffer/s_lock.c.

The design is reasonable, even if a little bit offbeat.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Nathan MyersDate: 2000-12-28 23:17:51
Subject: Re: Assuming that TAS() will succeed the first time is verboten
Previous:From: Mikheev, VadimDate: 2000-12-28 22:11:46
Subject: RE: Assuming that TAS() will succeed the first time is verboten

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