6.3.4 Approximate Limit Counter Implementation

Figure: Approximate Limit Counter Variables
\begin{figure}{ \scriptsize
\begin{verbatim}1 unsigned long __thread counter ...
...NLOCK(gblcnt_mutex);
8  ...

Figure: Approximate Limit Counter Balancing
\begin{figure}{ \scriptsize
\begin{verbatim}1 static void balance_count(void)...
...r = globalcount;
11 globalcount -= counter;
12 }\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-12-16