Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Programming Threads > how to best "ch...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 4032 of 4146
Post > Topic >>

how to best "characterize" a thread

by Arch Stanton <unknown@[EMAIL PROTECTED] > Sep 18, 2008 at 11:00 AM

This is an unusual thread question because it's not about thread 
programming per se but rather thread _auditing_. I'm working on a 
process auditing tool (think strace but put to a different purpose). 
Imagine that a threaded program is run twice under control of this 
auditor and the results are left in two output files "trace1" and 
trace2". I need to be able to "match up" the threads between trace1 and 
trace2 for comparison purposes. And BTW, for now I only want to consider 
pthreads; if the answer can be adapted to other implementations I can 
probably handle that myself later on.

The obvious answer is to compare thread ids but this breaks down pretty 
quickly. Some platforms issue random thread ids while others increment 
from 1, but even on the latter type, due to the basic asynchronous 
nature of threads, thread #3 in one run might be #4 in another.

Right now the best I can think of is a combination of (1) the address 
from which pthread_create() was called, (2) the address of the 
start_routine, and (3) the address of the argument to the start_routine. 
It seems to me that, though it's possible for that same combination to 
occur multiple times in the same process, even if they did the threads 
would be logically interchangeable (i.e. they'd be doing the same thing 
so it would be ok to treat them the same).

I can see at least one flaw in the above scheme; the data that the 'arg' 
pointer address could change even if the pointer itself didn't. I don't 
see an answer to that.

It might make sense to use the first argument to pthread_create (the 
address to which the thread id is written, as opposed to the id itself) 
as well, since I can't see it usually making sense to write multiple 
thread ids to the same place.

These are my ideas; does anyone have better ones? Or is this by chance a 
problem with a do***ented solution?

Thanks,
Arch Stanton
 




 8 Posts in Topic:
how to best "characterize" a thread
Arch Stanton <unknown@  2008-09-18 11:00:40 
Re: how to best "characterize" a thread
Eric Sosman <Eric.Sosm  2008-09-18 11:37:12 
Re: how to best "characterize" a thread
Arch Stanton <unknown@  2008-09-18 12:14:22 
Re: how to best "characterize" a thread
Eric Sosman <Eric.Sosm  2008-09-18 12:39:39 
Re: how to best "characterize" a thread
Arch Stanton <unknown@  2008-09-18 17:00:09 
Re: how to best "characterize" a thread
Eric Sosman <Eric.Sosm  2008-09-18 17:33:49 
Re: how to best "characterize" a thread
Markus Elfring <Markus  2008-09-22 14:56:46 
Re: how to best "characterize" a thread
James Kanze <james.kan  2008-09-23 01:09:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 7:47:31 CST 2008.