Rejigger wq header stuff

上级 de379bc2
...@@ -241,11 +241,6 @@ void uartintr(void); ...@@ -241,11 +241,6 @@ void uartintr(void);
void switchvm(struct proc*); void switchvm(struct proc*);
int pagefault(struct vmap *, uptr, u32); int pagefault(struct vmap *, uptr, u32);
// wq.c
int wq_trywork(void);
int wq_push(work *w);
void wq_dump(void);
// cilk.c // cilk.c
void initcilkframe(struct cilkframe*); void initcilkframe(struct cilkframe*);
#if CILKENABLE #if CILKENABLE
......
#pragma once #pragma once
#define WQSIZE 8192
class work; class work;
int wq_trywork(void); int wq_trywork(void);
int wq_push(work *w); int wq_push(work *w);
void initwq(void);
void wq_dump(void); void wq_dump(void);
size_t wq_size(void);
void initwq(void);
struct work { struct work {
virtual void run() = 0; virtual void run() = 0;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
typedef struct spinlock wqlock_t; typedef struct spinlock wqlock_t;
static inline void* static inline void*
allocwq(void) allocwq(unsigned long nbytes)
{ {
return ksalloc(slab_wq); return ksalloc(slab_wq);
} }
......
...@@ -16,9 +16,9 @@ mycpuid(void) ...@@ -16,9 +16,9 @@ mycpuid(void)
} }
static inline void* static inline void*
allocwq(void) allocwq(unsigned long nbytes)
{ {
return malloc(WQSIZE); return malloc(nbytes);
} }
static inline void static inline void
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "fmt.hh" #include "fmt.hh"
#include "sperf.hh" #include "sperf.hh"
#include "wq.hh"
#define BACKSPACE 0x100 #define BACKSPACE 0x100
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "cpu.hh" #include "cpu.hh"
#include "sched.hh" #include "sched.hh"
#include "percpu.hh" #include "percpu.hh"
#include "wq.hh"
struct idle { struct idle {
struct proc *cur; struct proc *cur;
......
...@@ -275,7 +275,7 @@ initkalloc(u64 mbaddr) ...@@ -275,7 +275,7 @@ initkalloc(u64 mbaddr)
slabmem[slab_kshared][c].ninit = CPUKSTACKS; slabmem[slab_kshared][c].ninit = CPUKSTACKS;
strncpy(slabmem[slab_wq][c].name, " wq", MAXNAME); strncpy(slabmem[slab_wq][c].name, " wq", MAXNAME);
slabmem[slab_wq][c].size = WQSIZE; slabmem[slab_wq][c].size = wq_size();
slabmem[slab_wq][c].ninit = NCPU; slabmem[slab_wq][c].ninit = NCPU;
for (int i = 0; i < slab_type_max; i++) { for (int i = 0; i < slab_type_max; i++) {
......
...@@ -42,7 +42,11 @@ private: ...@@ -42,7 +42,11 @@ private:
static wq *wq_; static wq *wq_;
static_assert(sizeof(wq) <= WQSIZE, "WQSIZE too small"); size_t
wq_size(void)
{
return sizeof(wq);
}
int int
wq_push(work *w) wq_push(work *w)
...@@ -76,7 +80,7 @@ void* ...@@ -76,7 +80,7 @@ void*
wq::operator new(unsigned long nbytes) wq::operator new(unsigned long nbytes)
{ {
assert(nbytes == sizeof(wq)); assert(nbytes == sizeof(wq));
return allocwq(); return allocwq(nbytes);
} }
wq::wq(void) wq::wq(void)
......
...@@ -18,9 +18,9 @@ mycpuid(void) ...@@ -18,9 +18,9 @@ mycpuid(void)
} }
static inline void* static inline void*
allocwq(void) allocwq(unsigned long nbytes)
{ {
return malloc(WQSIZE); return malloc(nbytes);
} }
static inline void static inline void
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论