Re: Using Threads?

From: Bruce Guenter <bruceg(at)em(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Using Threads?
Date: 2000-12-05 16:09:25
Message-ID: 20001205100925.A7398@em.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)em(dot)ca> http://em.ca/~bruceg/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-05 16:12:32 Re: Need help with phys backed shm segments (Postgresql+FreeBSD).
Previous Message Tom Lane 2000-12-05 16:01:53 Re: Need help with phys backed shm segments (Postgresql+FreeBSD).