[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fuse-devel
Subject:    Re: [fuse-devel] threading
From:       Bernd Schubert <bernd-schubert () gmx ! de>
Date:       2007-02-02 3:04:10
Message-ID: epu9na$fer$1 () sea ! gmane ! org
[Download RAW message or body]

Bernd Schubert wrote:

> Regarding to global variables I have the following problem:
> 
> Lets say we have a linked list as cache and the nodes of the linked list
> can "rotate", so the last node becomes first, second last node becomes
> last, etc.
> Though the rotation operation is rather fast, there might be a race
> condition during the rotation. Of course, I could try to do locking, but
> even locking requires some time and another, though less probable, race
> could happen. I have absolutely no experience with this kind of threading
> and I always wonder how it is done in the kernel.
> 

Answering myself to that problem, pthread locking using 

pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock (&mutex1);
pthread_mutex_unlock (&mutex1);

should do the trick (lock and unlock of course at the right places).



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
fuse-devel mailing list
fuse-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fuse-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic