OSThreads in the RTS

Simon Marlow simonmarhaskell at gmail.com
Wed Sep 26 06:39:20 EDT 2007


Cristian Perfumo wrote:
> 
> I am diving into the RTS, trying to identify where an OSThread is 
> created and where it is destroyed (join). The idea is to read some 
> hardware counters when it is just created and read them again when it is 
> about to be destroyed (for the time being let's ignore, for the sake of 
> understanding, the possibility of thread migration and context 
> switches). Does anyone know where to place these reads?

You might want to look at the PAPI stuff we have in GHC 6.8/HEAD, it's 
designed to measure hardware counters using the PAPI library.  See 
rts/Papi.c, for example.  We used this to get the measurements for our 
ICFP'07 paper on pointer tagging.

Unfortunately it doesn't currently work with multiple threads, which sounds 
like what you want.  But I bet it wouldn't be too hard to make it work.

You probably want to hook into at least startWorkerTask/workerTaskStop, 
these are the entry/exit points for a "worker" OS thread (created and 
managed by the RTS).  The other type of OS thread is a "bound" OS thread, 
created outside the RTS but making calls into Haskell code.  The entry/exit 
points in this case are newBoundTask and boundTaskExiting.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list