Paul van den Bogaard
2008-Feb-18 13:24 UTC
[dtrace-discuss] Initialisation of thread local vars
If I understand the docs correctly the only way to initialize self vars is automatic initialization: zero it is. I feel it would be very nice if we could explicitly initialize vars before their use. To values not zero that is. Currently I have a situation where the application uses just positive values. zero is a valid value here that therefore cannot be used to mean "uninitialized". I now need another self-> var telling me if the actual variable is initialized. This flag is set always when that other var is set. And needs always be used in the predicates to tests if that var has meaningful information. Using the value -1 only once would make the code more readable. Is this auto init of thread local variables there to stay (design?) or could it be an enhancement for a future version of DTrace? -- This message posted from opensolaris.org
Perry The Cynic
2008-Feb-19 03:33 UTC
[dtrace-discuss] Initialisation of thread local vars
What''s wrong with initializing those variables in the dtrace:::BEGIN probe? It''s guaranteed to run first, after all... Cheers -- perry -- This message posted from opensolaris.org
Perry The Cynic
2008-Feb-19 03:39 UTC
[dtrace-discuss] Initialisation of thread local vars
Never mind, I mis-read your question. Perhaps we should have a dtrace:::BEGIN-self probe that runs once for each thread? Cheers -- perry -- This message posted from opensolaris.org
Hi Paul, It''s not possible to set a value other than zero to be used as the default value for a variable. The use of zero as the default value is tied to how variables are allocated and freed internally. The initialization of new thread-local variables to zero is fairly baked into the design of DTrace and while it might seem suboptimal to require two variables in the case you described, that''s how you''ll have to do it. Adam On Feb 18, 2008, at 5:24 AM, Paul van den Bogaard wrote:> If I understand the docs correctly the only way to initialize self > vars is automatic initialization: zero it is. > > I feel it would be very nice if we could explicitly initialize vars > before their use. To values not zero that is. Currently I have a > situation where the application uses just positive values. zero is a > valid value here that therefore cannot be used to mean > "uninitialized". > I now need another self-> var telling me if the actual variable is > initialized. This flag is set always when that other var is set. And > needs always be used in the predicates to tests if that var has > meaningful information. > Using the value -1 only once would make the code more readable. > > Is this auto init of thread local variables there to stay (design?) > or could it be an enhancement for a future version of DTrace? > > > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl