wq tweaks

上级 ae573cc0
...@@ -23,6 +23,7 @@ struct stat; ...@@ -23,6 +23,7 @@ struct stat;
struct proc; struct proc;
struct vmap; struct vmap;
struct pipe; struct pipe;
struct work;
// bio.c // bio.c
void binit(void); void binit(void);
...@@ -324,11 +325,10 @@ void updatepages(pml4e_t*, void*, void*, int); ...@@ -324,11 +325,10 @@ void updatepages(pml4e_t*, void*, void*, int);
struct vmap * vmap_copy(struct vmap *, int); struct vmap * vmap_copy(struct vmap *, int);
// wq.c // wq.c
#if WQENABLE
int wq_trywork(void); int wq_trywork(void);
#else int wq_push(struct work *w);
#define wq_trywork() 0 struct work * allocwork(void);
#endif void freework(struct work *w);
// cilk.c // cilk.c
#if CILKENABLE #if CILKENABLE
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#define LOCKSTAT 0 #define LOCKSTAT 0
#define VERIFYFREE LOCKSTAT #define VERIFYFREE LOCKSTAT
#define ALLOC_MEMSET 1 #define ALLOC_MEMSET 1
#define WQENABLE 1
#define WQSHIFT 4 #define WQSHIFT 4
#if defined(HW_josmp) #if defined(HW_josmp)
#define NCPU 16 // maximum number of CPUs #define NCPU 16 // maximum number of CPUs
......
...@@ -375,8 +375,6 @@ scheduler(void) ...@@ -375,8 +375,6 @@ scheduler(void)
worked = wq_trywork(); worked = wq_trywork();
} while(worked); } while(worked);
sti(); sti();
if (!WQENABLE)
hlt();
} }
} }
} }
......
#if WQENABLE
#include "types.h" #include "types.h"
#include "kernel.h" #include "kernel.h"
#include "spinlock.h" #include "spinlock.h"
...@@ -47,13 +46,13 @@ wq_stat(void) ...@@ -47,13 +46,13 @@ wq_stat(void)
return &stat[cpunum()]; return &stat[cpunum()];
} }
static struct work * struct work *
allocwork(void) allocwork(void)
{ {
return (struct work *)kalloc(); return (struct work *)kalloc();
} }
static void void
freework(struct work *w) freework(struct work *w)
{ {
kfree(w); kfree(w);
...@@ -159,8 +158,8 @@ __wq_steal(int c) ...@@ -159,8 +158,8 @@ __wq_steal(int c)
static void static void
__wq_run(struct work *w) __wq_run(struct work *w)
{ {
void (*fn)(struct work*, void*, void*) = w->rip; void (*fn)(struct work*, void*, void*, void*, void*) = w->rip;
fn(w, w->arg0, w->arg1); fn(w, w->arg0, w->arg1, w->arg2, w->arg3);
freework(w); freework(w);
} }
...@@ -248,5 +247,3 @@ initwq(void) ...@@ -248,5 +247,3 @@ initwq(void)
for (i = 0; i < NCPU; i++) for (i = 0; i < NCPU; i++)
initlock(&queue[i].lock, "wq lock", LOCKSTAT_WQ); initlock(&queue[i].lock, "wq lock", LOCKSTAT_WQ);
} }
#endif // WQENABLE
...@@ -2,5 +2,7 @@ struct work { ...@@ -2,5 +2,7 @@ struct work {
void *rip; void *rip;
void *arg0; void *arg0;
void *arg1; void *arg1;
void *arg2;
void *arg3;
char data[]; char data[];
}; };
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论