Re: Using Threads? - Mailing list pgsql-hackers

From Bruce Guenter
Subject Re: Using Threads?
Date
Msg-id 20001205100925.A7398@em.ca
Whole thread Raw
In response to Re: Using Threads?  (Tom Samplonius <tom@sdf.com>)
List pgsql-hackers
On Mon, Dec 04, 2000 at 08:43:24PM -0800, Tom Samplonius wrote:
>   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.

Actually, context switch cost between threads is low on Linux as well,
since the CPU's VM mappings don't get invalidated.  This means that its
page tables won't get reloaded, which is one of the large costs involved
in context switches.  Context switches between processes takes (with no
significant VM) about 900 cycles (1.8us) on a 450MHz Celery.  I would
expect thread switch time to be slightly lower than that, and context
switches between processes with large VMs would be much larger just due
to the cost of reloading the page tables.
--
Bruce Guenter <bruceg@em.ca>                       http://em.ca/~bruceg/

pgsql-hackers by date:

Previous
From: Alfred Perlstein
Date:
Subject: Re: Need help with phys backed shm segments (Postgresql+FreeBSD).
Next
From: Tom Lane
Date:
Subject: Re: Need help with phys backed shm segments (Postgresql+FreeBSD).