The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How Can I use pthread_create ? shvalb High Level Programming 7 03-16-2009 05:00 AM
Profiling entire system activity with sysprof iBot UNIX and Linux RSS News 0 05-30-2008 12:50 PM
Pthread_create issue Hellboy High Level Programming 1 05-19-2008 07:58 AM
Kernel Profiling Ashok V UNIX for Advanced & Expert Users 0 04-17-2008 01:07 PM
unresolve pthread_create etc zhshqzyc High Level Programming 3 02-13-2006 06:38 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-27-2005
Vikky Panchal Vikky Panchal is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 3
Question Profiling..entry for a function in pthread_create

Hello,

i am try to write a profiler for a multithreaded applciation. When i creat e a thread for "function f2()" the profiling information for this function does not get captured in the struct profileManager. i;e i get the exit information for "function f2()" in that thread, but the entry information does not get captured. Is it because the profiling function "__cyg_profile_func_enter" does not get inserted fot that thread? Do i have to use pthread_once_t to initialize so that its entry gets profiled??

Thanks,
Vikky.

////**** This is my instrument.c file ****/////
static FILE *fp;

struct profileManager{
pid_t pth;
pthread_t th;
char Ch;
int addr;
struct timeval tp;
}pM[1000];

static int cnt=0;

void __cyg_profile_func_enter( void *this, void *callsite ) {
pthread_mutex_lock(&Lock);
pM[cnt].pth=getpid();
pM[cnt].th=pthread_self();
pM[cnt].Ch='E';
pM[cnt].addr=(int*)this;
gettimeofday(&pM[cnt].tp,NULL);
cnt++;
pthread_mutex_unlock(&Lock);
}


void __cyg_profile_func_exit( void *this, void *callsite ) {
pthread_mutex_lock(&Lock);
pM[cnt].pth=getpid();
pM[cnt].th=pthread_self();
pM[cnt].Ch='X';
pM[cnt].addr=(int*)this;
gettimeofday(&pM[cnt].tp,NULL);
cnt++;
pthread_mutex_unlock(&Lock);
}

////***** my sample code test.c ****/////
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>

int f1(int i){
sleep(1);
if(i==1)
return 0;
f1(i-1);
}

void f3(){
f1(5);
}

void* f2(void* arg){
f3();
}

void f4(){
sleep(1);
}


int main(){
int i;
pthread_t th;
int code;

code = pthread_create(&th,NULL,f2,NULL); ///Create Thread for F2
if(code==0)
printf("Thread created %d\n",th);
printf("Hello World\n");
(void)f2(NULL);
for(i=0;i<5;i++)
f4();
sleep(10);
return 0;
}
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0