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

Re: Using Threads?

From: Tom Samplonius <tom(at)sdf(dot)com>
To: Junfeng Zhang <junfengz(at)cae(dot)wisc(dot)edu>
Cc: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Using Threads?
Date: 2000-12-05 04:43:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Mon, 4 Dec 2000, Junfeng Zhang wrote:

> All the major operating systems should have POSIX threads implemented.
> Actually this can be configurable--multithreads or one thread.

  I don't understand this.  The OS can be configured for one thread?  How
would that be any of use?

> Thread-only server is unsafe, I agree. Maybe the following model can be a
> little better. Several servers, each is multi-threaded. Every server can
> support a maximum number of requests simultaneously. If anything bad
> happends, it is limited to that server. 

  There is no difference.  If anything bad happens with the current
multi-process server, all the postgres backends shutdown because the
shared memory may be corrupted.

> The cons side of processes model is not the startup time. It is about
> kernel resource and context-switch cost. Processes consume much more
> kernel resource than threads, and have a much higher cost for context
> switch. The scalability of threads model is much better than that of
> processes model.

  What kernel resources do a process use?  There is some VM mapping
overhead, a process table entry, and a file descriptor table.  It is
possible to support thousands of processes today.  For instance, supports up to 5000 FTP connections using a slightly
modified ftpd (doesn't use inetd anymore).  That means with 5000 users
connected, that works out to 5000 processes active.  Amazing but true.

  Some OSes (Linux is the main one) implement threads as pseudo processes.
Linux threads are processes with a shared address space and file
descriptor table.

  Context switch cost for threads can be lower if you are switching to a
thread in the same process.  That of course assumes that all context
switches will occur within the same process, or the Linux
everything-is-a-process model isn't used.

> -Junfeng


In response to


pgsql-hackers by date

Next:From: Tom LaneDate: 2000-12-05 05:06:41
Subject: Re: Using Threads?
Previous:From: Michael ForkDate: 2000-12-05 04:28:32
Subject: RE: SQL to retrieve FK's, Update/Delete action, etc. (fwd)

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