> This piece of advice is confusing. I think the author meant to make
> libraries thread-agnostic: don't bend over backwards to accommodate
> access to the same data from multiple threads, but don't unnecessarily
> couple different pieces of data either.
My take is simply don't use global variables or anything that would break a threaded application. Return contexts such that when you hold a lock around a context, things work as expected.
libabc: a demonstration library for kernel developers
Posted Nov 3, 2011 21:55 UTC (Thu) by nix (subscriber, #2304)
[Link]
I'd say that you can use global variables even in something supporting unlimited numbers of contexts, but if you do they should be threadsafe, not just thread-agnostic. (This is sometimes useful for cross-context caching and the like.)