Multithreaded or not?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Multithreaded or not?

Nikolaus Rath
Hello,

The apidoc tells me that fuse_main "calls either the single-threaded
or the multi-threaded event loop". Can somebody tell me how I can
determine or enforce which loop is actually called?

Also I couldn't find any information about threadwise initialization
functions. Is e.g. fuse_init called once per thread or only once on
startup of the process? I want to store my filesystem metadata in an
sqlite database and so I need a function where I can initialize a
separate database handle for each thread.


Thanks in advance,

   -Nikolaus

--
 »It is not worth an intelligent man's time to be in the majority.
  By definition, there are already enough people to do that.«
                                                         -J.H. Hardy

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Multithreaded or not?

Roberto -MadBob- Guido
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 02 July 2008 11:08:17 Nikolaus Rath wrote:
> Can somebody tell me how I can
> determine or enforce which loop is actually called?
>
With "-s" option you force the single-thread mode, otherwise it acts on
multi-thread.

> I want to store my filesystem metadata in an
> sqlite database and so I need a function where I can initialize a
> separate database handle for each thread.
>
I don't think it is a good idea to manage the same SQLite file with multiple
handlers at the same time, much better to have a single handler to protect
with a mutex.

- --
+--- -- -                                                 --  ----+
|   Roberto -MadBob- Guido ---+--- bob4mail[AT]gmail.com          |
|                             +--- madbob[AT]jabber.linux.it      .
.                             |
    Step #1 in programming:   +--- http://madbob.homelinux.com    |
|      understand people      +--- http://lobotomy.sf.net         |
|                             +--- http://barberaware.org         |
+--- ---- -                                              -- -  ---+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIbU4M3wUck/os3BkRAjXqAJ9+C2GpTTL9MDfDD9R9mNWz47d61QCfTvY2
W3Mufm2HOXNt06DWdcRNSow=
=W3Nz
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Multithreaded or not?

Nikolaus Rath
Roberto -MadBob- Guido <[hidden email]> writes:
> On Wednesday 02 July 2008 11:08:17 Nikolaus Rath wrote:
>> Can somebody tell me how I can
>> determine or enforce which loop is actually called?
>
> With "-s" option you force the single-thread mode, otherwise it acts
> on multi-thread.

Ahhh.. now that I know it's of course obvious. I was assuming that it
somehow depends on how I implement my filesystem and not that it's
just a command line option.

>> I want to store my filesystem metadata in an sqlite database and so
>> I need a function where I can initialize a separate database handle
>> for each thread.
>>
> I don't think it is a good idea to manage the same SQLite file with
> multiple handlers at the same time, much better to have a single
> handler to protect with a mutex.

That'd be cleaner, yes. But apparently it may provoke bugs on some
systems:

,----
| Prior to version 3.3.1, an sqlite3 structure could only be used in the
| same thread that called sqlite3_open() to create it. You could not
| open a database in one thread then pass the handle off to another
| thread for it to use. This was due to limitations (bugs?) in many
| common threading implementations such as on RedHat9. Specifically, an
| fcntl() lock created by one thread cannot be removed or modified by a
| different thread on the troublesome systems. And since SQLite uses
| fcntl() locks heavily for concurrency control, serious problems arose
| if you start moving database connections across threads.
`----

(http://www.sqlite.org/faq.html#q6)

When using the python interface, the handle even actively prevents
being called from different threads.

It therefore seems to me that it'd be safer to use separate handles,
or do I have to expect other problems in that case?


Best,

   -Nikolaus

--
 »It is not worth an intelligent man's time to be in the majority.
  By definition, there are already enough people to do that.«
                                                         -J.H. Hardy

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel