[comp.os.mach] Timing C Threads

john_r_mudd@stegosaur.cis.ohio-state.edu (03/30/90)

Does anyone have any suggestions on how to time the context switch
of C Threads (not kernel threads)?  I don't think timing a cthread_yield()
call is a good idea, because I'd guess that the primitive is a no-op unless
there are other threads available for execution.  Currently, I'm measuring
the difference between one thread signalling another thread, and the other 
thread waking up, e.g.

       thread 1                             thread 2

       condition_wait(switchsig,lock)       t0 = timer()
       t1 = timer()                         condition_signal(switchsig)

Care is taken to ensure that thread 1 executes the wait before the thread
2 signals.  Time to wakeup a thread would equal (t1-t0).

Any thoughts/comments/suggestions?

... John


  ..........................................................................

  John R. Mudd                                        jrm@cis.ohio-state.edu
  Department of Computer and Information Science,  The Ohio State University
  2036 Neil Avenue, Columbus, Ohio, USA   43210-1277