Re: [OpenSTA-devel] Re: Platform SDK
Brought to you by:
dansut
|
From: Mark E. <ma...@bo...> - 2006-01-19 23:15:46
|
Daniel Sutcliffe wrote: > Peter Wickersham wrote: > >>I'm testing my random patch in the next day or so. The only issue >>that I am not clear on is whether or not I need to guard the calls >>into the MTRand class (Mersenne Twister Random). It is not >>threadsafe, but is this a major issue? I am not sure if we are >>guarded upstream of these calls due to the use of MUTEX statements >>in the SCL and other possible mutexes. Anyone know this? > > > It's a good question and one I, unfortunately, don't know the answer > to. The fact that Mark was concerned about the lack of controlled > atomicity to the srand(),rand() pair would suggest to me that you do > need to be somewhat concerned - Mark would have more idea than most > as one of the original coders of this area. I'll try and have a look at the weekend but if memory serves... Using a MUTEX around your GENERATE and NEXT statements in SCL should have the desired effect of 'protecting' the random variable, assuming, of course, that the MTRand class is entirely contained as a member of the CECVar derived class. However, I believe that the original purpose of having the MUTEX and SEMAPHORE statements was more to do with allowing synchronisation across virtual users for the purposes of atomicity on multiple SCL statements and avoiding data race between unrelated scripts, rather than the simple 'guarding' outlined above. Certainly, if this is the case, it could be argued that we should allow the use of variables to be thread safe without the need for extra SCL statements. I do not believe that this is currently, explicitly, true. However, the internal workings of the threading model used and the mechanisms of CORBA used for the GLOBAL variables may mean that this does not cause a problem for most situations. The threading, in particular, has changed since I wrote the variable code, and the CORBA variable handling has been moved to within the Daemon process rather than the old TestManager Process(where it was guaranteed that CORBA variable objects would be destroyed at the end of a test). But I think the actual variable handling is still pretty much the same. In short I would say, I think that thread-safety is an issue, but that it may be difficult to prove :-) Mark |