6.3.4 Approximate Limit Counter Implementation

Figure: Approximate Limit Counter Variables
\begin{figure}{ \scriptsize
\begin{verbatim}1 atomic_t __thread counterandmax...
...< CM_BITS) \vert cm;
32 return ((int)cami);
33 }\end{verbatim}
}\end{figure}

Figure: Approximate Limit Counter Balancing
\begin{figure}{ \scriptsize
\begin{verbatim}1 int add_count(unsigned long del...
...61 spin_unlock(&gblcnt_mutex);
62 return 1;
63 }\end{verbatim}
}\end{figure}

Because this implementation (count_lim_app.c) is quite similar to that in the previous section (Figures [*], [*], and [*]), only the changes are shown here. Figure [*] is identical to Figure [*], with the addition of MAX_COUNTERMAX, which sets the maximum permissible value of the per-thread countermax variable.

Similarly, Figure [*] is identical to the balance_count() function in Figure [*]), with the addition of lines 5 and 6, which enforce the MAX_COUNTERMAX limit on the per-thread countermax variable.



Paul E. McKenney 2011-02-12