Instrument syscall and schedule.

上级 1bdda0cc
......@@ -5,6 +5,7 @@
#include "x86.h"
#include "proc.h"
#include "spinlock.h"
#include "xv6-mtrace.h"
struct {
struct spinlock lock;
......@@ -257,6 +258,13 @@ void
scheduler(void)
{
struct proc *p;
int pid;
acquire(&ptable.lock);
pid = nextpid++;
release(&ptable.lock);
mtrace_fcall_register(pid, (unsigned long)scheduler, 0, mtrace_start);
for(;;){
// Enable interrupts on this processor.
......@@ -274,7 +282,11 @@ scheduler(void)
proc = p;
switchuvm(p);
p->state = RUNNING;
mtrace_fcall_register(pid, 0, 0, mtrace_pause);
mtrace_fcall_register(proc->pid, 0, 0, mtrace_resume);
swtch(&cpu->scheduler, proc->context);
mtrace_fcall_register(pid, 0, 0, mtrace_resume);
switchkvm();
// Process is done running for now.
......@@ -302,6 +314,8 @@ sched(void)
if(readeflags()&FL_IF)
panic("sched interruptible");
intena = cpu->intena;
mtrace_fcall_register(proc->pid, 0, 0, mtrace_pause);
swtch(&proc->context, cpu->scheduler);
cpu->intena = intena;
}
......
......@@ -5,6 +5,7 @@
#include "proc.h"
#include "x86.h"
#include "syscall.h"
#include "xv6-mtrace.h"
// User code makes a system call with INT T_SYSCALL.
// System call number in %eax.
......@@ -126,11 +127,17 @@ void
syscall(void)
{
int num;
num = proc->tf->eax;
if(num >= 0 && num < NELEM(syscalls) && syscalls[num])
if(num >= 0 && num < NELEM(syscalls) && syscalls[num]) {
mtrace_fcall_register(proc->pid, (unsigned long)syscalls[num],
0,
mtrace_start);
proc->tf->eax = syscalls[num]();
else {
mtrace_fcall_register(proc->pid, (unsigned long)syscalls[num],
0,
mtrace_done);
} else {
cprintf("%d %s: unknown sys call %d\n",
proc->pid, proc->name, num);
proc->tf->eax = -1;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论