From e557e9564abe26495b516332fec90016bc4760ac Mon Sep 17 00:00:00 2001 From: William Cohen Date: Wed, 10 Dec 2008 10:38:53 -0500 Subject: Edit text sections on associative arrays. Also tweak example two space indent. --- .../en-US/Array-Operations.xml | 148 ++++++++++----------- 1 file changed, 73 insertions(+), 75 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml b/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml index 8fe46721..789bf607 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml @@ -263,7 +263,7 @@ delta = gettimeofday_s() - foo[tid()] array_name[index_expression] ++ -Again, you can also use a handler function for your index_expression. For example, if you wanted to tally how many times a specific process performed a read to the virtual file system (using the event kernel.function("vfs_read")), you can use the following probe: +Again, you can also use a handler function for your index_expression. For example, if you wanted to tally how many times a specific process performed a read to the virtual file system (using the event vfs.read), you can use the following probe: @@ -299,9 +299,9 @@ delta = gettimeofday_s() - foo[tid()] vfsreads.stp -probe kernel.function("vfs_read") +probe vfs.read { - reads[execname()] ++ + reads[execname()] ++ } @@ -430,12 +430,12 @@ probe kernel.function("vfs_read") global reads probe vfs.read { - reads[execname()] ++ + reads[execname()] ++ } probe timer.s(3) { - foreach (count in reads) - printf("%s : %d \n", count, reads[count]) + foreach (count in reads) + printf("%s : %d \n", count, reads[count]) } @@ -500,8 +500,8 @@ probe timer.s(3) probe timer.s(3) { - foreach (count in reads- limit 10) - printf("%s : %d \n", count, reads[count]) + foreach (count in reads- limit 10) + printf("%s : %d \n", count, reads[count]) } @@ -591,13 +591,13 @@ probe timer.s(3) global reads probe vfs.read { - reads[execname()] ++ + reads[execname()] ++ } probe timer.s(3) { - foreach (count in reads) - printf("%s : %d \n", count, reads[count]) - delete reads + foreach (count in reads) + printf("%s : %d \n", count, reads[count]) + delete reads } @@ -608,20 +608,20 @@ probe timer.s(3) global reads probe vfs.read { - reads[execname()] ++ - + reads[execname()] ++ } -probe timer.s(2) + +probe timer.s(3) { - printf("=======\n") - foreach (count in reads+) - printf("%s : %d \n", count, reads[count]) - delete reads + printf("=======\n") + foreach (count in reads+) + printf("%s : %d \n", count, reads[count]) + delete reads } --> -In , the second probe prints the number of VFS reads each process made within the probed 2-second period only. The delete reads statement clears the reads array within the probe. +In , the second probe prints the number of VFS reads each process made within the probed 3-second period only. The delete reads statement clears the reads array within the probe. Note @@ -651,34 +651,34 @@ probe timer.s(2) clearing arrays/array elements array operations - You can have multiple array operations within the same probe. Using the examples from and , you can track the number of VFS reads each process makes per 2-second period and tally the cumulative VFS reads of those same processes. Consider the following example: + You can have multiple array operations within the same probe. Using the examples from and , you can track the number of VFS reads each process makes per 3-second period and tally the cumulative VFS reads of those same processes. Consider the following example: global reads, totalreads -probe kernel.function("vfs_read") +probe vfs.read { - reads[execname()] ++ - totalreads[execname()] ++ + reads[execname()] ++ + totalreads[execname()] ++ } -probe timer.s(2) +probe timer.s(3) { - printf("=======\n") - foreach (count in reads+) - printf("%s : %d \n", count, reads[count]) - delete reads - + printf("=======\n") + foreach (count in reads+) + printf("%s : %d \n", count, reads[count]) + delete reads } + probe end { - printf("TOTALS\n") - foreach (total in totalreads+) - printf("%s : %d \n", total, totalreads[total]) + printf("TOTALS\n") + foreach (total in totalreads+) + printf("%s : %d \n", total, totalreads[total]) } -In this example, the arrays reads and totalreads track the same information, and are printed out in a similar fashion. The only difference here is that reads is cleared every 2-second period, whereas totalreads keeps growing. +In this example, the arrays reads and totalreads track the same information, and are printed out in a similar fashion. The only difference here is that reads is cleared every 3-second period, whereas totalreads keeps growing.
@@ -711,39 +711,38 @@ probe end global reads probe vfs.read { - reads[execname()] ++ + reads[execname()] ++ } -probe timer.s(2) +probe timer.s(3) { - printf("=======\n") - foreach (count in reads-) - if (reads[count] >= 1024) - printf("%s : %dkB \n", count, reads[count]/1024) - else - printf("%s : %dB \n", count, reads[count]) + printf("=======\n") + foreach (count in reads-) + if (reads[count] >= 1024) + printf("%s : %dkB \n", count, reads[count]/1024) + else + printf("%s : %dB \n", count, reads[count]) } -Every two seconds, prints out a list of all processes, along with how many times each process performed a VFS read. If the associated value of a process name is equal or greater than 1024, the if statement in the script converts and prints it out in kB. +Every three seconds, prints out a list of all processes, along with how many times each process performed a VFS read. If the associated value of a process name is equal or greater than 1024, the if statement in the script converts and prints it out in kB.