This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

working with private variables in a multi-threaded env


Hello,

I'm working on a module that can be reduced to one
that will count how many times `foo' is called in a
user code. The module will scan through the user code,
and will add `counter++' before every call to `foo'.
The problem is that the user code is independent, and
a problem arises when it's threaded. It should be
obvious that `counter' is not threadsafe and may
record wrong results. Unfortunately, I can't use locks
since it will incur huge overhead in performance (
e.g., inside a huge for loop with a large number of
threads).

The solution I'm heading toward now is privatizing
`counter' to each thread (i.e., __is_thread). Does
anyone have any ideas/suggestions(/solutions? :-o) to
how would one go about collecting these private variables?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]