How does sampling Profiler work?

M

Morgan Cheng

Hi,

I am curious that how sampling profiler works.
How can a program(profiler) know the running detailis of another program?

I googled this topic and not much info is got. Is there anybody get some
insight about it?

Thanks & Regards,
 
A

Andy Lomax

Hi,

I am curious that how sampling profiler works.
How can a program(profiler) know the running detailis of another program?

I googled this topic and not much info is got. Is there anybody get some
insight about it?

Basically, you use a second process to examine what's happening in the
first process.

The obvious way to do this is to get your OS kernel to examine process
1 during timer interrupts. The timer interrupts process 1 regularly
(say, 50 or 100 times a second). The kernel records where the PC was
in process 1, storing the result in an array, before returning control
to process 1. When process 1 completes, the profiler gets this array
from the kernel, and translates the PC addresses into locations in the
source program using process 1's symbol table. Look up Unix's
profile() (I think that's right - I forget what the exact name is)
system call.

Easy!

AL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top