Rejigger wq header stuff

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