tracking threads?

With the following code, how can I keep track of number of blocks and other information about the two threads created in this main program?
I tried pidin and pidin -F “name of program” but doesn’t seemed to give good interaction information between threads, or maybe I might not be using it correctly. Any thought?? Thanks

ps: why does doing “pidin -F test_Thread”, give me bunch of test_Thread as an output? what does the number of “test_Thread” print out mean? I have only created two threads so I would expect only two “test_Thread” but it seems to give way more than that.

void Thread(void arg)
if ((char)arg[1]==‘S’)
while (1)
printf("%c %d\n",(char
while (1)
printf("%c %d\n",(char
int main()
void *argv[2];
void *argv2[2];
int rc;
pthread_t e_th;
pthread_t f_th;
pthread_attr_t attr;

	pthread_attr_init( &attr );
    argv[1]=(void *)'S';
    argv[2]=(void *)2;
    rc = pthread_create(&e_th, NULL, &Thread,(void *) &argv);
    if (rc)
	argv2[1]=(void *)'F';
	argv2[2]=(void *)1;
    rc = pthread_create(&f_th, NULL, &Thread,(void *) &argv2);
    if (rc)
    return 0;


Well I don’t know about “way more” but you should have 3 threads. Perhaps you are running multiple instances of the executable ?


When I do pidin, I only see one executable running (which is “test_Thread”. But when I do pidin -F test_Thread, I see like 10 or 15 of it, and it doesn’t even print out any other information about the thread.
What’s going on? Is my code wrong?

The -F option to pidin takes a format string as an argument. Your “test_Thread” doesn’t contain any formatting codes (see the docs for pidin), so pidin prints the string as-is once for each process that’s running on your system.

If you don’t want to specify a format string, put two dashes at the end of the options:

pidin -F – arg

you mean pidin -F test_Thread –
like this?

First of all, pidin has a specific list of arguments that it recognizes (e.g. arg, mem, timers). If you enter:

pidin test_Thread

it complains about invalid shorthand – many of the arguments have a short form(e.g. “m” is short for “mem”).

The arguments specify what information you want to get about all of the processes on your system, not the name of the processs you want information for. To get information only for test_Thread, try something like this:

pidin | grep test_Thread

As for the -F option, I was slightly wrong. If you specify an argument (e.g. pidin -F – arg), the argument overrides the -F option. If you type:

pidin -F

it complains that -F needs a format string. The double dash means “end of arguments” to most Unix-style utilities. Adding it, as you did, to the end of the command doesn’t do anything.