plan9fox/sys/src/9/port/dtracytimer.c
cinap_lenrek 4f0bfe0fb8 dtracy: avoid dmachlock() race
between being commited to a machno and having acquired the lock, the
scheduler could come in an schedule us on a different processor. the
solution is to have dtmachlock() take a special -1 argument to mean
"current mach" and return the actual mach number after the lock has
been acquired and interrupts being disabled.
2019-03-30 09:17:46 +01:00

53 lines
758 B
C

#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include <dtracy.h>
static DTProbe *timerprobe;
static void
dtracytimer(void *)
{
DTTrigInfo info;
memset(&info, 0, sizeof(info));
for(;;){
tsleep(&up->sleep, return0, nil, 1000);
dtptrigger(timerprobe, &info);
}
}
static void
timerprovide(DTProvider *prov)
{
timerprobe = dtpnew("timer::1s", prov, nil);
}
static int
timerenable(DTProbe *)
{
static int gotkproc;
if(!gotkproc){
kproc("dtracytimer", dtracytimer, nil);
gotkproc=1;
}
return 0;
}
static void
timerdisable(DTProbe *)
{
}
DTProvider dtracytimerprov = {
.name = "timer",
.provide = timerprovide,
.enable = timerenable,
.disable = timerdisable,
};