Hi,
Global variables are not thread-safe and 'j' in your script is a global
variable. This explains why you don't see a list of numbers sorted in
ascending order.
Regards,
Krishnan
On Fri, 2009-04-17 at 18:03 +0800, Qihua Wu wrote:
> Hi, All,
>
> For the following script, I hope the printed number should be
> sequential and ordered. But the fact is not, anyone knows the reason
> or bug?
> #!/usr/sbin/dtrace -s
> #pragma D option quiet
> BEGIN
> {
> j=0;
> }
> profile:::tick-10ms
> {
> i=1;
> }
> syscall:::
> /i==1/
> {
> i=0;
> j=j+1;
> printf("%d\n",j);
> }
>
>
> bash-3.00$ ./a.d ===> I hope the ouptut is
> 1,2,3,4,5,..... instead of 1,7,11,16 in a disordered way.
> 1
> 5
> 13
> 14
> 18
> 38
> 47
> 48
> 57
> 58
> 63
> 74
> 2
> 3
> .....
>
> _______________________________________________
> dtrace-discuss mailing list
> [email protected]
_______________________________________________
dtrace-discuss mailing list
[email protected]