提交 523ac2a9 创建 作者: Austin Clements's avatar Austin Clements

Un-bit-rot mtrace

Fix some compile errors (mtstart depended on C's implicit cast from function pointers to void* and user.h lacked some extern "C" function declarations mtrace needed) and some logic errors (mtstart wasn't happening in idle procs and there was a perplexing mtpause going out of sched).
上级 3ab59330
...@@ -7,7 +7,8 @@ struct kstack_tag { ...@@ -7,7 +7,8 @@ struct kstack_tag {
extern struct kstack_tag kstack_tag[NCPU]; extern struct kstack_tag kstack_tag[NCPU];
// Tell mtrace about switching threads/processes // Tell mtrace about switching threads/processes
static inline void mtstart(void *ip, struct proc *p) template<typename Ret, typename... Args>
static inline void mtstart(Ret (*ip)(Args...), struct proc *p)
{ {
unsigned long new_tag; unsigned long new_tag;
int i; int i;
......
...@@ -36,6 +36,8 @@ int setfs(u64 base); ...@@ -36,6 +36,8 @@ int setfs(u64 base);
int stat(char*, struct stat*); int stat(char*, struct stat*);
int fstatat(int dirfd, const char*, struct stat*); int fstatat(int dirfd, const char*, struct stat*);
char* strcpy(char*, const char*); char* strcpy(char*, const char*);
char* strncpy(char *s, const char *t, size_t n);
void* memcpy(void *dst, const void *src, size_t n);
void* memmove(void*, const void*, size_t); void* memmove(void*, const void*, size_t);
char* strchr(const char*, char c); char* strchr(const char*, char c);
int strcmp(const char*, const char*); int strcmp(const char*, const char*);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "sched.hh" #include "sched.hh"
#include "percpu.hh" #include "percpu.hh"
#include "wq.hh" #include "wq.hh"
#include "kmtrace.hh"
struct idle { struct idle {
struct proc *cur; struct proc *cur;
...@@ -89,7 +90,7 @@ idleloop(void) ...@@ -89,7 +90,7 @@ idleloop(void)
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys. // Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// mtrace_call_set(1, cpu->id); // mtrace_call_set(1, cpu->id);
//mtstart(scheduler, idlep); mtstart(idleloop, myproc());
sti(); sti();
for (;;) { for (;;) {
......
...@@ -84,7 +84,6 @@ sched(void) ...@@ -84,7 +84,6 @@ sched(void)
next->set_state(RUNNING); next->set_state(RUNNING);
next->tsc = rdtsc(); next->tsc = rdtsc();
mtpause(next);
if (next->context->rip != (uptr)forkret && if (next->context->rip != (uptr)forkret &&
next->context->rip != (uptr)threadstub) next->context->rip != (uptr)threadstub)
{ {
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论