On Fri, Apr 03, 2009 at 05:40:44PM +0100, Andrew Gabriel wrote: > I have a dtrace variable which is a counter which I'm incrementing on entry > to a kernel function, and decrementing on function return, so I expect the > value to be the number of threads which are currently in that function. > However, the value slowly climbs to values way higher than the number of > threads I could possible have in the function. It's rather like what I'd > expect if I was manipulating a counter in C from lots of threads without > protection from a mutex, and indeed if I turn off all except 1 CPU, the > counter seems to work perfectly and give me the values I'd expect. > > So, is there anyway to safely have multiple threads increment and decrement > a counter? I guess I could use an array indexed by cpu, but I can't think > how to add together all the array elements to get the total, which I'm > using in a tick probe.
Hi Andrew, Take a look at the documentation for aggregations: that's the mechanism you want to use for what you describe above. Adam -- Adam Leventhal, Fishworks http://blogs.sun.com/ahl _______________________________________________ dtrace-discuss mailing list dtrace-discuss@opensolaris.org