I presume that what you are doing cannot be handled by /proc/taskid/(whatever...)?
Or by any of the existing counters and metrics already available in the kernel?
Within the kernel, accessing any one of the task-structures is comparatively easy (so long as you properly lock it), and accessing a list of task-IDs is also comparatively easy. But in the general case, attempting to access every task in-detail would be a very expensive and failure-prone thing to do. Especially in a multiprocessor system: it would basically force the whole world to stop and wait for you.
You see, "the lock that owns the task-list" does not cover every task structure in that list: each one of these is individually locked. The task-list locks simply regulate insertion and deletion, i.e. the integrity of the list itself.
If you can by any means accomplish your objective, "close-enough," by means of the existing information published to user-space in /proc/taskid, you should definitely do so.
|