Log of /trunk/core/thread/src/TThread.cxx
Parent Directory
Revision
45617 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Aug 15 16:11:52 2012 UTC (2 years, 5 months ago) by
pcanal
File length: 33869 byte(s)
Diff to
previous 43098
From Elvin and Philippe:
In TJoinHelper::Join check the predicate value (fJoined) both when the TimedWaited return due to a timeout or due to receiving the signal
and unconditionally breakout in case of errors.
Elvin tracked down the issue. Basically, there is a deadlock in the TJoinHelper::Join method.
The problem is when the helper thread tries to signal the main thread then the join is done. This is achieved by using the conditional variable fC. But, it can be that the helper thread gets the lock in the TJoinHelper::JoinFunc method around line 117 and the requesting threads tries to wait in line 136 but the time-out expires before the helper thread sends the signal and releases the lock ( one can easily reproduce this by adding a sleep(3) after lline 117). So, now the requesting thread is blocked waiting to get the lock for the mutex. Say now that the helper thread sends the signal and releases the lock. The signal is lost as the requesting thread was not not in the TimedWait and the helper threads exits. Therefore. we end up in a situation that there is no one to send the signal to the requesting tread that the join was done properly.
The simple change that I've done is line 148:
if (fJoined) break;
Because is doesn't matter that much if we received the signal or not as long as the join was done properly. Also notice that this test is done while the mutex is held by the requesting thread so there is no danger of any race conditions.
Revision
41108 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Oct 4 07:25:09 2011 UTC (3 years, 3 months ago) by
pcanal
File length: 33276 byte(s)
Diff to
previous 41086
Do not use the user accessible 'global' lock to protect the internals of TThread,
instead use an internal (but still global) mutex.
Having the ambiguity leads to an easy uncesserary dead-lock.
Thread1:
1. Acquire TThread::Lock
2. TFile::Open
3. TClass::GetClass()
7. TClass::Init
8. wait for gCINTGlobalMutex
Thread2:
3. TFile::Open
4. TClass::GetClass()
5. TClass::init
6. Acquire gCINTGlobalMutex
9. TNamed::SetName
10. use gPad
11. call TThread::Tsd
12. call TThread::Self
13. wait for ever and ever on TThread::Lock ....
Revision
41086 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Sep 30 21:27:53 2011 UTC (3 years, 3 months ago) by
pcanal
File length: 32783 byte(s)
Diff to
previous 40890
Introduce TThreadSlots.h to centralize and formalize the use of the TThread local memory slots amongst the ROOT packages.
Move the definition of gThreadTsd to TROOT.cxx.
Revision
40890 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Sep 15 13:37:40 2011 UTC (3 years, 4 months ago) by
rdm
File length: 32627 byte(s)
Diff to
previous 39640
From Andrei:
The thread-specific data container is not initialized so one cannot
test if some slot in the array is being used or not.
Revision
39640 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Jun 9 16:40:51 2011 UTC (3 years, 7 months ago) by
pcanal
File length: 32589 byte(s)
Diff to
previous 39262
Improve behavior of TJoinHelper given the following limitation
of the pthread conditions:
// When using condition variables there is always a Boolean predicate
// involving shared variables associated with each condition wait that
// is true if the thread should proceed. **Spurious** wakeups from the
// pthread_cond_timedwait() or pthread_cond_wait() functions may occur.
// Since the return from pthread_cond_timedwait() or pthread_cond_wait()
// does not imply anything about the value of this predicate, the
// predicate should be re-evaluated upon such return.
Revision
39262 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu May 19 09:10:49 2011 UTC (3 years, 8 months ago) by
rdm
File length: 31774 byte(s)
Diff to
previous 35527
Add new static method TThread::Initialize() that will activate the ROOT
mutexes without the need to create an actual thread.
Also added a number of protections and comments on return codes.
Revision
34685 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Sat Jul 31 15:08:32 2010 UTC (4 years, 5 months ago) by
pcanal
File length: 30377 byte(s)
Diff to
previous 32890
Add a clear easy way to tell whether any TThread is in use (this is needed by r34682).
TThread::IsInitalized() now returns true as soon as TThread object is used.
Revision
24077 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Sat May 31 19:39:09 2008 UTC (6 years, 7 months ago) by
brun
File length: 29972 byte(s)
Diff to
previous 22961
Extend the TInterpreter class to support the CINT API used so far by ROOT.
The concrete implementation of the class is in TCint.
The new functions are essentially interfaces to the existing CINT C++ classes
like G__ClassInfo, G__CallFunc, G__DataMemberInfo, G__MethodInfo, G__TypeInfo
and G__TypedefInfo. Most of these functions will call the Reflex interface
once the CINT/Reflex interface will be available later this year.
All direct calls to CINT are replaced by calls like gCint->ClassInfo_xxx where gCint
points to the TCint implementation.
The existing calls to TCint via gInterpreter are kept because on Windows
gInterpreter does not call directly TCint, but instead call TWin32InterpreterProxy
that in turns call TCint.
On Linux and Mac, gInterpreter and gCint are equivalent.
Once the transformation using gCint will be completed, it will be possible
to specify at startup time which version of CINT (CINT or CINT7) by loading
dynamically TCint or TCint7.--This line, and those below, will be ignored--
M core/meta/src/TStreamerElement.cxx
M core/meta/src/TCint.cxx
M core/meta/src/TGlobal.cxx
M core/meta/src/TBaseClass.cxx
M core/meta/src/TDataMember.cxx
M core/meta/src/TInterpreter.cxx
M core/meta/src/TClass.cxx
M core/meta/src/TMethodArg.cxx
M core/meta/src/TDataType.cxx
M core/meta/src/TMethodCall.cxx
M core/meta/src/TIsAProxy.cxx
M core/meta/src/TMethod.cxx
M core/meta/src/TFunction.cxx
M core/meta/inc/TClass.h
M core/meta/inc/TDictionary.h
M core/meta/inc/TMethodArg.h
M core/meta/inc/TDataType.h
M core/meta/inc/TMethodCall.h
M core/meta/inc/TMethod.h
M core/meta/inc/TFunction.h
M core/meta/inc/TCint.h
M core/meta/inc/TGlobal.h
M core/meta/inc/TBaseClass.h
M core/meta/inc/TDataMember.h
M core/meta/inc/TInterpreter.h
M core/thread/src/TThread.cxx
M core/base/src/TVirtualFitter.cxx
M core/base/src/TStorage.cxx
M core/base/src/TQConnection.cxx
M core/base/src/TROOT.cxx
M core/base/src/TSystem.cxx
M core/base/src/TQObject.cxx
M core/rint/src/TRint.cxx
M core/rint/src/TTabCom.cxx
M math/foam/src/TFoam.cxx
M math/minuit2/src/TFitterMinuit.cxx
M math/mathcore/src/FunctorCint.cxx
M math/minuit/src/TMinuit.cxx
M tree/tree/src/TTree.cxx
M tree/tree/src/TSelectorCint.cxx
M tree/tree/src/TSelector.cxx
M tree/tree/inc/TSelectorCint.h
M roofit/roofitcore/src/RooGenCategory.cxx
M roofit/roofitcore/src/RooWorkspace.cxx
M hist/hist/src/TF1.cxx
M gui/guibuilder/src/TGuiBldDragManager.cxx
M net/alien/inc/TAlienSystem.h
Revision
22961 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Apr 3 13:32:57 2008 UTC (6 years, 9 months ago) by
rdm
File length: 29957 byte(s)
Diff to
previous 21532
move the directories:
base clib cont meta metautils newdelete pcre rint thread unix utils
winnt zip
under the new core meta directory.
Revision
20411 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Oct 19 12:37:58 2007 UTC (7 years, 3 months ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 29943 byte(s)
Diff to
previous 19826
remove conditional around include of RConfigure.h:
#ifdef R__HAVE_CONFIG
#include "RConfigure.h"
#endif
Having this conditional caused RConfigure.h to be missing from the .d
files and hence these files would not be recompiled after re-configuring
using --prefix.
Revision
18326 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Sun Mar 18 18:35:22 2007 UTC (7 years, 10 months ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 30031 byte(s)
Diff to
previous 17735
From Bertrand:
Here is a patch for win32 implementation of TThread.
- Improves speed of a factor 10 in a heavy context switching
threaded application (by using critical sections).
- Added R__LOCKGUARD2(gROOTMutex) in TThreadTimer.
- Added CINT deadlock workaround for WIN32 in TMutex :-\
- Protected calls to gInterpreter->Execute() in TCanvas.
- Added gSystem->Sleep(10) in tutorial threadsh1.C
Revision
17412 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Sat Jan 20 19:29:35 2007 UTC (8 years ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 29883 byte(s)
Diff to
previous 16824
-Remove Varargs.h from TString.h and TObject.h and add this include
in the few files that need it.
-Move the following enums from TBuffer.h to TBufferFile.h
enum { kMapSize = 503 };
enum { kStreamedMemberWise = BIT(14) }; //added to version number to know if a collection has been stored member-wise
enum { kNotDecompressed = BIT(15) }; //indicates a weird buffer, used by TBasket
enum { kCannotHandleMemberWiseStreaming = BIT(17), //if set TClonesArray should not use memeber wise streaming
kTextBasedStreaming = BIT(18) }; // indicates if buffer used for XML/SQL object streaming
Revision
16796 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Nov 16 17:18:32 2006 UTC (8 years, 2 months ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 31141 byte(s)
Diff to
previous 15601
Changes to get rid of the config.h and HAVE_CONFIG define. These were way
too trivial (just do a locate config.h to see how many there are):
- replace occurances of config.h by RConfigure.h
- add #warning in config.h that is should not be used
- change HAVE_CONFIG to R__HAVE_CONFIG
Revision
15134 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue May 23 04:47:42 2006 UTC (8 years, 8 months ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 31115 byte(s)
Diff to
previous 15034
From Federico Carminati:
"I have implemented all copy and equal operators needed to silence all
warnings in AliRoot, as requested. I have implemented shallow copies as
would do the default operators synthetized by the compiler.
Most operators are protected. If users complain, you just have to move
them into the public area, but class derivation is of course supported.
It has been a terrible job, I have modified 278 files, but the changes
are backward compabile, and this goes a long way to permitting user to
use the effc++ flag with root headers."
Revision
14988 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed May 10 15:31:03 2006 UTC (8 years, 8 months ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 29848 byte(s)
Diff to
previous 14034
introduce a TGlobalMutexGuard class where the dtor sets the gGlobalMutex
to 0. Create a global static TGlobalMutexGuard object which will cause
the TGlobalMutexGuard dtor to be called when libThread is unloaded (at the
end of a ROOT program). This fixes problems with ROOT crashing at exit
because gGlobalMutex was not 0 and still accessed while the Thread library
was already unloaded.
Revision
12123 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Jun 22 20:18:12 2005 UTC (9 years, 7 months ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 29226 byte(s)
Diff to
previous 11687
From Constantin Loizides
This patch implements:
- decentralized, automatic mutex initialization,
see R__LOCKGUARD2 in TVirtualMutex
- PROOF parallel startup fixes
- more thread protection (in base, cont, meta, rest to be done)
- cleanups
From Eddy Offermann:
TString::Atoi and Atof are made const.
Revision
11687 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Apr 28 16:14:28 2005 UTC (9 years, 8 months ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 29476 byte(s)
Diff to
previous 11101
From Gerri:
Patch introducing parallel startup of the slave servers. This new feature
will considerably reduce the startup time in PROOF setups with many 10's
to 100's of slaves. By default this feature is off, turn it on in the
[system].rootrc file by uncommenting the line:
Proof.ParallelStartup: yes
Summary of changes:
Index: Makefile
- Add the thread lib to PROOFLIBS
Index: base/inc/TVirtualMutex.h, base/src/TVirtualMutex.cxx
- Add global mutexes to protect printing and authentication
Index: base/src/TError.cxx
- Protect static buffer in DebugPrint with specific global mutex
Index: config/Makefile.depend
- Add dependence on thread lib for PROOF
Index: config/rootrc.in
- Add description of new envs
Proof.ParallelStartup, Auth.Timeout, ProofServ.UseSSH
Index: net/inc/TAuthenticate.h
- Add new member fTimeout to indicate timeout situations
and new method HasTimedOut() to retrieve it.
- Add new static member with the timeout value in sec
and method SetTimeOut() to set it
- Add new method CatchTimeOut() called at timeout expiration
Index: net/inc/THostAuth.h , net/src/THostAuth.cxx
- Add new method SetLast() to lower pririty of an attempted
protocol that has timed-out
Index: net/src/TAuthenticate.cxx
- Implementation of the new timeout setup using TTimer
- Add protection using specific global mutex
- change to start with lower case some local variables
in Authenticate
- re-introduce call to THostAuth::CountFailure() (which got
lost in a previous patch)
- Disable by default SSH for PROOF servers
- fix a couple of small memory leaks
Index: net/src/TPSocket.cxx
- Fix logic in Close() (if called too early (e.g. timeout)
the underlying socket can still be open and needs to be
closed).
Index: net/src/TSocket.cxx
- initialize member fTcpWindowSize in all constructors
- modify error logging after an unsuccessful authentication
attempt, checking for timeouts.
- disable SSH for PROOF servers
Index: proof/inc/TProof.h
- patch for parallel startup using threads:
- new methods SlaveStartupThread(void *) and
SubmasterStartupThread(void *) executed in threads
- add Bool_t argument to all implementations of StartSlaves
Index: proof/src/TProof.cxx
- patch for parallel startup using threads:
- add internal classes ProofThread and ProofThreadArg to keep
track of started threads and to pass arguments to threads
- cleanup fPlayer and fFeedBack in destructor
Index: rpdutils/src/rpdutils.cxx
- fix small memory leak
Index: thread/src/TThread.cxx
- initialize new global mutexes
Revision
10774 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Dec 14 15:06:18 2004 UTC (10 years, 1 month ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 28785 byte(s)
Diff to
previous 10755
several important changes and fixes:
- remove dependence on direct G__xxx CINT code, since CINT is not
reentrant there is no change we can currently run interprered function
as thread functions. This avoids also usage of the CINT lock in
the thread code which could lead to deadlocks when threads were
created in a constructor of an object created via the plugin manager
(which uses CINT to execute the ctor).
- added thread safe versions for the DoError() and ErrorHandler() functions
which allows TThread::Info() and family to be called from threads.
Idem for the Printf() function.
- by Maarten, added a join helper thread that will avoid the main thread
from blocking while doing a join and thereby not being able to process
events or handle messages sent from the threads via the XARequest
method.
- fix several memory leaks (valgrind).
Revision
10748 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Dec 10 12:13:33 2004 UTC (10 years, 1 month ago) by
rdm
Original Path:
trunk/thread/src/TThread.cxx
File length: 25771 byte(s)
Diff to
previous 10466
From Maarten and me:
Changelog:
- Fixed a problem with TSemaphore where the owner of the lock in
the associated TMutex was not properly updated by the low level
pthread_cond_wait relock. (always remember our TMutex in TCondition)
- Unify thread ID's as Long_t
- Simplify and regularize TThread::Join(). Join with a thread based on
tid or TThread *, hide implementation more cleanly, remove unnecessary
member functions and variables (fJoinId et al)
- Make TThread::Ps() static (easier from cmd line)
- Use -1 iso 0 for unknown thread id as 0 is a valid value
- add more error checking in lots of places
- move gContainerMutex and gCINTMutex initialisation with the rest of
the one time init bunch.
- Simpify Exists()
- Lock *all* access to the global thread list
Revision
5726 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Dec 3 16:44:25 2002 UTC (12 years, 1 month ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 24823 byte(s)
Diff to
previous 4668
From Mathieu de Naurois <denauroi@in2p3.fr>
"From the manual of pthread_cond_timedwait, I have:
pthread_cond_timedwait atomically unlocks mutex and waits on
cond, as pthread_cond_wait does, but it also bounds the duration
of the wait. If cond has not been signaled within the amount
of time specified by abstime, the mutex mutex is re-acquired
and pthread_cond_timedwait returns the error ETIMEDOUT.
The abstime parameter specifies an absolute time, with the same
origin as time(2) and gettimeofday(2): an abstime of 0
corresponds to 00:00:00 GMT, January 1, 1970.
In the code of ROOT, the line:
while (fgXAct) {fgXActCondi->TimedWait(1);}
was a nonsense that it equivalent to :
while(fgXAct);
and it uses 100% of CPU.
I modified the TThread class in the version we use for HESS.
For us, in a heavily multithreaded DAQ, this modified version works fine
and is faster when opening canvases from threads."
Revision
4056 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Feb 22 09:37:29 2002 UTC (12 years, 11 months ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 24002 byte(s)
Diff to
previous 3468
Patch from Mathieu de Naurois adding Thread-safety in many ROOT classes.
A new TVirtualMutex global is defined in TVirtualMutex.h (gCINTmutex).
gCINTMutes is used in TMethodCall to protect concurrent access to CINT.
The R__LOCKGUARD macro is introduced in many classes to check for a mutex.
The performance penalty introduced by the MUTEX logic
-is ZERO in the application has no threads
-about 10% in case of threads
Revision
2588 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Jul 17 14:38:41 2001 UTC (13 years, 6 months ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 23852 byte(s)
Diff to
previous 2506
Proposed by Mathieu de Naurois: a new option kMETH in TThread::Xaction.
A function may be executed by the main Thread via a TMethodCall.
Example of use:
void DaqRead::CanvasManager::Update()
{
// We made the update occur in the Main Thread
// to avoid dead lock with mouse/pad action
// which can lock the DaqRead::CanvasManager::mutex
if (gThreadXAR) {
TMethodCall c(IsA(),"Update","");
void *arr[4];
arr[1] = &c;
arr[2] = (void *)this;
arr[3] = (void*)"";
if ((*gThreadXAR)("METH", 4, arr, NULL)) return;
}
mutex.Lock();
Emit("Update()");
mutex.UnLock();
}
Revision
2385 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Jun 6 13:41:43 2001 UTC (13 years, 7 months ago) by
brun
Original Path:
trunk/thread/src/TThread.cxx
File length: 23595 byte(s)
Diff to
previous 2357
The following mods by Mathieu de Naurois. The following was an email from Matthieu
"You set the Thread Id at two different places.
1) in Int_t TPosixThread::Run(TThread *th)
th->fId = id; SetUniqueID(th->fId);
2)in void *TThread::Fun(void *ptr)
th = (TThread *)ptr;
th->fId = SelfId(); th->SetUniqueID(th->fId);
The second solution is the only good one, because the Thread uses its it
in the TThread::Fun
function. So if TPosixThread::Run was not fast enough, you get a clash.
BUT, in TThread::Fun(void *ptr) you use the Id before assigning it, in
the following call
CleanUpPush((void *)&AfterCancel,th); // Enable standard cancelling
function
So, I suggest to move the Id definition before that call."
This form allows you to request diffs between any two revisions of this file.
For each of the two "sides" of the diff,
enter a numeric revision.