summaryrefslogtreecommitdiff
path: root/sys/src/9/kw
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-10-25 20:17:39 +0200
committercinap_lenrek <cinap_lenrek@centraldogma>2011-10-25 20:17:39 +0200
commit3fce94e7850ab80d14fa15f2f393ae71259376e5 (patch)
treec9eb3d2b3b52130690c1fcce43afabd4e9adfcdd /sys/src/9/kw
parent83865180a29d7feba2a1f460abf17315562141c3 (diff)
fix _tos->pcycles, make _tos->kcycles actually count cycles executing kernel code on behalf of the process
Diffstat (limited to 'sys/src/9/kw')
-rw-r--r--sys/src/9/kw/arch.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/src/9/kw/arch.c b/sys/src/9/kw/arch.c
index e481d5c58..85ef31835 100644
--- a/sys/src/9/kw/arch.c
+++ b/sys/src/9/kw/arch.c
@@ -50,7 +50,7 @@ kexit(Ureg*)
tos = (Tos*)(USTKTOP-sizeof(Tos));
t = fastticks(nil);
tos->kcycles += t - up->kentry;
- tos->pcycles = up->pcycles;
+ tos->pcycles = t + up->pcycles;
tos->cyclefreq = Frequency;
tos->pid = up->pid;
@@ -124,11 +124,16 @@ void
procsetup(Proc* p)
{
fpusysprocsetup(p);
+
+ cycles(&p->kentry);
+ p->pcycles = -p->kentry;
}
void
-procfork(Proc *)
+procfork(Proc* p)
{
+ p->kentry = up->kentry;
+ p->pcycles = -p->kentry;
}
/*
@@ -141,6 +146,7 @@ procsave(Proc* p)
cycles(&t);
p->pcycles += t;
+ p->kentry -= t;
fpuprocsave(p);
}
@@ -152,8 +158,10 @@ procrestore(Proc* p)
if(p->kp)
return;
- t = lcycles();
+
+ cycles(&t);
p->pcycles -= t;
+ p->kentry += t;
fpuprocrestore(p);
}