Thread safe ?

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

Thread safe ?

Quentin Arce
Hi,

Are all calls to the user space file system
serialized?

In other words, is it safe to have a global variable
that is touched by multiple functions?

If not, I understand I will need to use locking.

Thanks,

Q


       
               
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Thread safe ?

Joshua J. Berry
On Tuesday 06 September 2005 13:14, Quentin Arce wrote:
> Hi,
>
> Are all calls to the user space file system
> serialized?

They can be.  You get this by passing the "-s" option to fuse_main(), I
believe.  If -s isn't passed, FUSE will run in multithreaded mode (i.e. you
need locking).

--
Joshua J. Berry

"I haven't lost my mind -- it's backed up on tape somewhere."
    -- /usr/games/fortune

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Thread safe ?

Quentin Arce


--- "Joshua J. Berry" <[hidden email]>
wrote:

> On Tuesday 06 September 2005 13:14, Quentin Arce
> wrote:
> > Hi,
> >
> > Are all calls to the user space file system
> > serialized?
>
> They can be.  You get this by passing the "-s"
> option to fuse_main(), I
> believe.  If -s isn't passed, FUSE will run in
> multithreaded mode (i.e. you
> need locking).

Thank you!!!

Q

>
> --
> Joshua J. Berry
>
> "I haven't lost my mind -- it's backed up on tape
> somewhere."
>     -- /usr/games/fortune
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

RE: Thread safe ?

JoelKatz
In reply to this post by Quentin Arce

> Hi,
>
> Are all calls to the user space file system
> serialized?
>
> In other words, is it safe to have a global variable
> that is touched by multiple functions?
>
> If not, I understand I will need to use locking.
>
> Thanks,
>
> Q

        Even if all the calls were serialized, you could still need locking.
Locking doesn't just provide serialization and mutual exclusion, it ensures
memory visibility. If you're using POSIX threads and want to have one thread
read a memory allocation, even if you are sure it is after another thread
has modified it, you still must ensure memory visibility by one of the
specific methods POSIX provides. Otherwise the other thread could read a
stale value (or, theoretically, any value) even if you are sure it runs
after the modifying thread.

        To clarify, if you have:

int i=0;
int j=0;

        And one thread does:

i=5;
j=2;

        And another thread does:

if(j==2)
{
 if(i==0) bomb();
}

        There is no guarantee that 'bomb' will not be called. Serialization is not
sufficient.

        DS




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: RE: Thread safe ?

Quentin Arce
--- David Schwartz <davidavidsmaster.com> wrote:

>
> > Hi,
> >
> > Are all calls to the user space file system
> > serialized?
> >
> > In other words, is it safe to have a global
> variable
> > that is touched by multiple functions?
> >
> > If not, I understand I will need to use locking.
> >
> > Thanks,
> >
> > Q
>
> Even if all the calls were serialized, you could
> still need locking.
> Locking doesn't just provide serialization and
> mutual exclusion, it ensures
> memory visibility. If you're using POSIPOSIXeads and
> want to have one thread
> read a memory allocation, even if you are sure it is
> after another thread
> has modified it, you still must ensure memory
> visibility by one of the
> specific methods POSIPOSIXvides. Otherwise the other
> thread could read a
> stale value (or, theoretically, any value) even if
> you are sure it runs
> after the modifying thread.
>

Thank you very much for your help.  I really
apriappreciate  Do you have any good pointers to good
sites which go over more of these types of cases?

Thanks again.



> To clarify, if you have:
>
> int i=0;
> int j=0;
>
> And one thread does:
>
> i=5;
> j=2;
>
> And another thread does:
>
> if(j==2)
> {
>  if(i==0) bomb();
> }
>
> There is no guarantee that 'bomb' will not be
> called. Serialization is not
> sufficient.
>
> DS
DS
>
>
>
>
-------------------------------------------------------
> SF.Net email is Sponsored by the Better Software
> Conference & EXPO
> September 19-22, 2005 * San Francisco, CA *
> Development LifeLifecyclectices
> Agile & Plan-Driven Development * Managing Projects
> & Teams * Testing & QA
QASecurity * Process Improvement & Measurement *
> httphttpww.www.sqe/bscebsce
> _______________________________________________
> fuse-devedevelling list
> fuse-devedevelts.soursourceforge
> httphttpsists.soursourceforge/lists/listlistinfoe-devedevel


       
               
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel