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

Re: Support for QNX6, POSIX IPC and PTHREAD-style locking

From: "Igor Kovalenko" <Igor(dot)Kovalenko(at)motorola(dot)com>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Support for QNX6, POSIX IPC and PTHREAD-style locking
Date: 2001-11-24 09:06:44
Message-ID: 161001c174c7$577a95d0$20e00518@c773082g (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
----- Original Message -----
From: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Igor Kovalenko" <Igor(dot)Kovalenko(at)motorola(dot)com>
Cc: <pgsql-patches(at)postgresql(dot)org>
Sent: Friday, November 23, 2001 2:14 PM
Subject: Re: [PATCHES] Support for QNX6, POSIX IPC and PTHREAD-style locking

> I want to comment on this patch.  The author is not happy to have all
> his QNX6 work wait for 7.3 so I suggested he split the patch in two:
> one part that is seen only by QNX and regression stuff, and a second
> patch that adds Posix semaphore support.  I think the first part can be
> put into 7.2 if we can all be sure it is seen only by QNX.

We had some more discussion with Bruce on the nature of changes.
Essentially, my point is that all the changes will only be seen on QNX6,
with or without Posix semaphore stuff, unless other platforms will
explicitly enable new code. I could simply use #ifdef __QNX__ everywhere and
not have this discussion, but since Posix semaphore code could be usable for
other platforms, I decided to use a 'feature key' rather than 'platform
key'. So the code is guarded by #ifdef HAVE_POSIX_IPC and can be enabled on
platform-specific basis. The patch will only enable it on QNX6 so it is as
'tight' as '#ifdef __QNX__' would be. Eventually maintainers of other
platforms can try it and enable if they like.

To prove my point I tried to build patched version on Linux 2.2 (Suse 6.4)
and Solaris (2.5/Sparc and 8/Intel). It compiled well and passed all
regression tests except geometry (which fails due to usual numeric precision

That of course still does not cover *all* platforms. I could probably try to
check on AIX and HP/UX but not all supported platforms anyway. I believe
however that if there were problems with patch, either Linux or Solaris
would expose them.

I also tried to use Posix semaphores on those platforms and it worked
perfectly well on Solaris 8 (it needed proper flags to compiler though). On
Linux Posix semaphores can not be shared between processes, so it is of no
use for postgres (unless new Linux versions fix that issue).

Guess it comes down to vote. I can also do what Bruce suggested (separate
patches) if I still did not convince everyone that patch won't hurt as is.
Please vote which way you like it (none, separate QNX6 & Posix sem,

- igor

> FYI, we support QNX4, but not QNX6 at this point.
> --------------------------------------------------------------------------
> > Here is the patch which adds following things to 7.2:
> >
> > 1. Support for QNX6 (builds cleanly on stock installation and passes all
> > regression tests).
> >
> > 2. HAVE_POSIX_IPC feature, which if enabled switches implementation of
> > IpcSemaphoreXXX() (ipc.[ch]) to POSIX semaphores and mmap(). Enabled on
> > but should be useful for lot of platforms. Since IpcSemaphoreCreate()
> > assumed SysV semaphores, I had to change its prototype *when* this
> > is enabled. That function is called from proc.c and spin.c, which were
> > patched accordingly for POSIX case (with #ifdef guards).
> >
> > 3. USE_PTHREAD_MUTEXES feature, which if enabled implements S_LOCK stuff
> > with PTHREAD mutexes. It is useful (better than spinlocks) on non-SMP
> > systems when overhead of kernel call is small compared to overhead of
> > scheduling. Enabled on QNX6.
> >
> > 4. USE_PTHREAD_SPINLOCKS feature which if enabled implements S_LOCK
> > with PTHREAD spinlocks (may not be available on all platforms). It might
> > better on SMP systems when hardware does not support TAS (in which case
> > semaphores would be used as of now and it is hard to be worse than
> > MIPS systems come to mind (and QNX6 runs on them, so it will be enabled
> > QNX6 in such cases).
> >
> > I haven't put checks for (2), (3) or (4) into configure to not break
> > supported platforms in unexpected ways. Benefits of (3) and (4) are
> > OS and hardware dependent, so if you think they could be useful for your
> > platform, they have to be enabled in appropriate OS-specific header.
> >
> > Same for HAVE_POSIX_IPC, but that one in fact can be useful on lot of
> > platforms. I've seen benchmark suggesting POSIX semaphores are 4 times
> > faster on Linux than SysV ones. It certainly applies to QNX4 as well and
> > makes emulation of SysV stuff unnecessary. I believe it could be
extended to
> > support platforms like Darwin and BeOS which currently also rely on SysV
> > emulation. If there's interest from involved people, we could come up
with a
> > better unified abstraction model and implementations for all supported
> > platforms...
> >
> > I've been warned it might be considered too 'major' for 7.2, but please
> > at the patch before judging. I tried my best to not break existing
> > all changes are only activated when explicitly enabled, QNX6-specific or
> > obviously compatible (the only 'unguarded' changes are typecasts for
> > like SemId = -1, since its type is pointer in case of POSIX and fix for
> > broken QNX qsort() which I believe is already commited into CVS). I've
> > considerable time doing this and would really appreciate if it went into
> > 7.2. Code builds and runs clean with or without any of above features
> > enabled.
> >
> > The patch generated as recursive GNU-diff between original 7.2b2 and
> > (+ make distclean) top level directories, like 'diff -crP pgsql-original
> > pgsql-patched'.
> > It is big mostly because it contains whole new files for QNX6 (-P treats
> > missing files as empty).
> >
> > regards,
> > - igor
> >
> [ Attachment, skipping... ]
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
> --
>   Bruce Momjian                        |
>   pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to


pgsql-patches by date

Next:From: Weiping HeDate: 2001-11-24 14:35:50
Subject: Re: Chinese NLS patch, the third try.
Previous:From: Bruce MomjianDate: 2001-11-23 20:14:01
Subject: Re: Support for QNX6, POSIX IPC and PTHREAD-style locking

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