[comp.unix.internals] Scheduling of processes, and timers

daniel@sdl.mdcbbs.com (06/13/91)

    
    I've written a program which interrupts another process every few
milliseconds and takes a copy of the stack. This information is later
processed to give profile information.

    I use sigitimer to wake myself up, and ptrace to interupt the other
process and take a copy of its stack. This has been developed on 
Sparcstations running SunOs4.1, but should work on other Unix variants.
   
Anyway I have two problems :-
                           
 1) Scheduling, the process doing the interrupting appears to get 
    scheduled during system calls in the process being monitored. In
    particular there is a very large bias to ioctl.

        Is scheduling likely to take place at system calls ?
        Is there a way round this if this is so ?
        Do I just give up and use gprof ?

 2) The timer resolution on a Sparc 2 is 100Hz, and as it is an
    umpty frumpt MIP box even if I cross the first hurdle I'll miss
    large chunks of code.

        Is there any other timer available on Sparcstations ?

Thanks

    Daniel Dignam
    daniel@sdl.mdcbbs.com

-- 
Daniel Dignam                           Shape Data Limited (McDonnell Douglas)
 Internet: daniel@sdl.mdcbbs.com           46 Regent Street
     UUCP: ...!uunet!sdl.mdcbbs.com!daniel   Cambridge CB2 1DB
    Voice: +44 223 316673  Fax: +44 223 316931  United Kingdom

torek@elf.ee.lbl.gov (Chris Torek) (06/19/91)

In article <1991Jun13.141021.1@sdl.mdcbbs.com> daniel@sdl.mdcbbs.com writes:
>... developed on Sparcstations running SunOs4.1, but should work on other
>Unix variants. ... Is scheduling likely to take place at system calls ?

Yes.

>        Is there a way round this if this is so ?

No (at least, not without major kernel changes).

>        Do I just give up and use gprof ?

Probably.  You can implement your own profiler; gprof is simply convenient
(see profil(2)).

> 2) The timer resolution on a Sparc 2 is 100Hz ...

This is purely a software issue on the SparcStations.  The actual timers
count in microseconds.  Of course, the software in question is the kernel;
you need kernel source to change it.

>        Is there any other timer available on Sparcstations ?

SparcStations have two timers, one intended for use as the scheduling
clock (often set to interrupt 100 times a second) and one intended for
use as a profiling clock (it interrupts at a much higher priority, and
can be set differently).  Ideally gprof will use the profiling clock,
running at a higher rate.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov