> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of D. Richard Hipp
> Sent: Friday, May 15, 2009 1:03 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] SQLite spawns multiple processes?
> 
> 
> On May 15, 2009, at 1:21 PM, <logan.rat...@emerson.com>
> <logan.rat...@emerson.com
>  > wrote:
> 
> > I don't know what causes it, but I see the exact same thing running
an
> > embedded 2.6.17 kernel on a PPC architecture.  And my application is
> > decidedly single-threaded. Oddly enough, the exact same application
> > running on multiple 2.6 kernels running on i86 machines does not
show
> > this behavior.
> >
> 
>  From a comment in the os_unix.c source file (which implements the
> SQLite backend for all unix-like systems):
> 
> ** Yet another problem:  LinuxThreads do not play well with posix
locks.
> **
> ** Many older versions of linux use the LinuxThreads library which is
> ** not posix compliant.  Under LinuxThreads, a lock created by thread
> ** A cannot be modified or overridden by a different thread B.
> ** Only thread A can modify the lock.  Locking behavior is correct
> ** if the appliation uses the newer Native Posix Thread Library (NPTL)
> ** on linux - with NPTL a lock created by thread A can override locks
> ** in thread B.  But there is no way to know at compile-time which
> ** threading library is being used.  So there is no way to know at
> ** compile-time whether or not thread A can override locks on thread
B.
> ** We have to do a run-time check to discover the behavior of the
> ** current process.
> 
> The run-time check mentioned in the last sentence involves creating a
> new thread and experimenting to see how it interacts with posix
> advisory locks.  I'm guessing that extra thread is what you are seeing
> as a second process.

That could be.  Is it expected that this 'extra' thread never exits?  On
my system once it appears it never goes away.  strace tells me that it's
not doing much (it calls poll() and getppid() about once every two
seconds), but it does hang around.

> One always runs into a bazillion subtle problems like this when you
> get into threads.  I keep trying to tell y'all that threads are evil.
> I wish you'd listen.....

Holy wars aside, as I said, my application is single threaded.

> If you recompile SQLite with -DSQLITE_THREADSAFE=0 then all of the
> above code is omitted and you should not get any extra process table
> entries.

That would be terrific.  While it doesn't seem to break anything, I
would like to have the process resources back.  Thanks!

> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Logan Ratner | Software Engineer | Gas Chromatographs
Emerson Process Management | 5650 Brittmoore Rd | Houston | TX | 77041 |
USA
T +1 713 839 9656 | F +1 713 827 3807
logan.rat...@emerson.com

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to