Sponsored Content
Top Forums UNIX for Advanced & Expert Users Profiling..entry for a function in pthread_create Post 82068 by Vikky Panchal on Saturday 27th of August 2005 05:42:08 AM
Old 08-27-2005
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;
}
 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Kernel Profiling

I compiled my device driver with the profiling option -p but while linking I am getting undefined reference to _mcount. LD /vobs/femto_drivers/DspBiosLink/dsplinkk/src/dsplinkk.o Building modules, stage 2. MODPOST *** Warning: "_mcount" undefined! Architechture: ppc32 From... (0 Replies)
Discussion started by: Ashok V
0 Replies

2. UNIX for Dummies Questions & Answers

profiling execution of a process

question goes like this : Explain how users can profile execution of a process with help of an example? can some one pls give me the answer?? (1 Reply)
Discussion started by: rakesh1988
1 Replies

3. Programming

pthread_create

The prototype for pthread_create function is like this:- int pthread_create(pthread_t *thread,pthread_attr_t *attr,void *(*start routine),void *arg); Q.1 .Why the return type of the start_routine must be void*?? Q.2. Why should we pass arg by converting into void * only ?? Thank You (3 Replies)
Discussion started by: sunil_abhay
3 Replies

4. Programming

Profiling results and SMP

The SCO OSR 5.7 system was migrated from older HP DL360 to new DL380 G7. The SMP feature was not activated on older box, it is activated now on this 4 core Xeon. A s/w we maintain has been copied without any change over to the new box. I noticed that the application profiling does not show any... (4 Replies)
Discussion started by: migurus
4 Replies

5. AIX

C profiling tool for AIX

Hello everybody, Please let me know if there are any free C profiling tool for AIX environment Thanks in advance (0 Replies)
Discussion started by: SteAlma
0 Replies

6. How to Post in the The UNIX and Linux Forums

Help me, write a bash script to delete parent entry with all their child entry in LDAP UNIX server

Hi All, Please help me and guide me to write a bash/shell script on Linux box to delete parent entry with all their child entries. example: Parent is : ---------- dn: email=yogesh.kumar@wipro.com, o=wipro, o=in child is: ---------- dn: cn: yogesh kumar, email=yogesh.kumar@wipro.com,... (1 Reply)
Discussion started by: Chand
1 Replies

7. Debian

Profiling Processes while shutdown

I was wondering how can I find the culprit of a slow shutdown on my debian box? I am actually looking for a diagnosis tool that might dump the process name and amount of time it took to close the process after signal was send. As for now I am trying to use journalctl to seek some information,... (5 Replies)
Discussion started by: Varun Pandey
5 Replies
LM-PROFILER(8)						      System Manager's Manual						    LM-PROFILER(8)

NAME
/usr/sbin/lm-profiler - laptop mode profiler SYNOPSIS
/usr/sbin/lm-profiler DESCRIPTION
This manual page documents briefly the /usr/sbin/lm-profiler command. lm-profiler is a tool for profiling disk operations. It is a part of laptop mode tools and is useful only in relation to rest of laptop mode tools. It helps you to detect programs and services that use up system resources and that cause disk activity, and it allows you to disable them when laptop mode is active. When you start lm-profiler, it will execute a "profiling run", which can take some time. Start lm-profiler when you are working on batter- ies, preferably, because that will allow it to analyze the actual situation that it is supposed to optimize. During the profiling run, you can use your system normally; however, any disk activity caused by your actions will end up in the profiler's results. When the profiling run is finished, you will be presented with a list of programs that deserve your attention, either because they listen on a network (which is not usually useful when you are working offline) or because they caused disk activity in a disk-spindown-unfriendly pattern. When lm- profiler can guess an init script that belongs to a program, it presents you with the opportunity to disable the program when you are work- ing on battery. It does this by placing a link to the init script in /etc/laptop-mode/batt-stop. Any programs that lm-profiler cannot find an init script for is simply reported, so that you can stop the program manually if you want to. WARNING ABOUT DISABLING PROGRAMS: It may not be safe to disable some programs. They may be needed for proper operation of your system. Dis- able services only if you know what they do and why you don't need them. FILES
/etc/lm-profiler.conf lm-profiler retrieves its profiling rules from this file. SEE ALSO
lm-profiler.conf(8). laptop-mode.conf(8). daemons.conf(8). AUTHOR
This manual page was written by Bart Samwel (bart@samwel.tk) and Jan Polacek (jerome@ucw.cz) for the Debian system (but may be used by oth- ers). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. LM-PROFILER(8)
All times are GMT -4. The time now is 02:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy