Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
d5bf5447
提交
d5bf5447
4月 01, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
x
上级
286cbb04
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
192 行增加
和
92 行删除
+192
-92
wq.hh
include/wq.hh
+42
-0
wqkernel.hh
include/wqkernel.hh
+1
-9
wqtypes.hh
include/wqtypes.hh
+12
-0
wquser.hh
include/wquser.hh
+1
-38
Makefrag
kernel/Makefrag
+2
-1
wqkern.cc
kernel/wqkern.cc
+45
-0
Makefrag
lib/Makefrag
+1
-1
wqlib.cc
lib/wqlib.cc
+4
-40
wquser.cc
lib/wquser.cc
+83
-0
param.h
param.h
+1
-1
wqlinux.hh
user/wqlinux.hh
+0
-2
没有找到文件。
include/wq.hh
浏览文件 @
d5bf5447
#pragma once
#pragma once
#include "wqtypes.hh"
#include "percpu.hh"
class
work
;
class
work
;
int
wq_trywork
(
void
);
int
wq_trywork
(
void
);
...
@@ -38,6 +41,45 @@ struct wframe {
...
@@ -38,6 +41,45 @@ struct wframe {
volatile
int
v_
;
volatile
int
v_
;
};
};
#define NSLOTS (1 << WQSHIFT)
class
wq
{
public
:
wq
();
int
push
(
work
*
w
,
int
tcpuid
);
int
trywork
();
void
dump
();
static
void
*
operator
new
(
unsigned
long
);
private
:
work
*
steal
(
int
c
);
work
*
pop
(
int
c
);
void
inclen
(
int
c
);
void
declen
(
int
c
);
struct
wqueue
{
work
*
w
[
NSLOTS
];
volatile
int
head
__mpalign__
;
volatile
int
tail
;
wqlock_t
lock
;
};
struct
stat
{
u64
push
;
u64
full
;
u64
pop
;
u64
steal
;
};
percpu
<
wqueue
>
q_
;
percpu
<
stat
>
stat_
;
#if defined(XV6_USER)
uwq_ipcbuf
*
ipc_
;
#endif
};
#if defined(LINUX)
#if defined(LINUX)
#include <stdlib.h>
#include <stdlib.h>
#include <assert.h>
#include <assert.h>
...
...
include/wqkernel.hh
浏览文件 @
d5bf5447
#include "
types.
h"
#include "
wqtypes.h
h"
#include "kernel.hh"
#include "kernel.hh"
#include "spinlock.h"
#include "spinlock.h"
#include "amd64.h"
#include "amd64.h"
#include "cpu.hh"
#include "cpu.hh"
#include "kalloc.hh"
#include "kalloc.hh"
#include "wq.hh"
typedef
struct
spinlock
wqlock_t
;
static
inline
void
*
static
inline
void
*
allocwq
(
unsigned
long
nbytes
)
allocwq
(
unsigned
long
nbytes
)
...
@@ -38,9 +35,4 @@ wqlock_init(wqlock_t *lock)
...
@@ -38,9 +35,4 @@ wqlock_init(wqlock_t *lock)
initlock
(
lock
,
"wq lock"
,
LOCKSTAT_WQ
);
initlock
(
lock
,
"wq lock"
,
LOCKSTAT_WQ
);
}
}
static
inline
void
wqarch_init
(
void
)
{
}
#define xprintf cprintf
#define xprintf cprintf
include/wqtypes.hh
0 → 100644
浏览文件 @
d5bf5447
#pragma once
#if defined (LINUX)
typedef
pthread_spinlock_t
wqlock_t
;
#elif defined(XV6_KERNEL)
#include "types.h"
#include "spinlock.h"
typedef
struct
spinlock
wqlock_t
;
#else
#include "uspinlock.h"
typedef
struct
uspinlock
wqlock_t
;
#endif
include/wquser.hh
浏览文件 @
d5bf5447
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#include "uspinlock.h"
#include "uspinlock.h"
#include "amd64.h"
#include "amd64.h"
#include "user.h"
#include "user.h"
#include "wq.hh"
#include "pthread.h"
#include "pthread.h"
#include "memlayout.h"
#include "memlayout.h"
#include "uwq.hh"
#include "uwq.hh"
...
@@ -12,15 +11,7 @@
...
@@ -12,15 +11,7 @@
typedef
struct
uspinlock
wqlock_t
;
typedef
struct
uspinlock
wqlock_t
;
static
pthread_key_t
idkey
;
int
mycpuid
(
void
);
static
std
::
atomic
<
int
>
nextid
;
static
volatile
int
exiting
;
int
mycpuid
(
void
)
{
return
(
int
)(
u64
)
pthread_getspecific
(
idkey
);
}
static
inline
void
*
static
inline
void
*
allocwq
(
unsigned
long
nbytes
)
allocwq
(
unsigned
long
nbytes
)
...
@@ -64,34 +55,6 @@ wqlock_init(wqlock_t *lock)
...
@@ -64,34 +55,6 @@ wqlock_init(wqlock_t *lock)
initlock
(
lock
);
initlock
(
lock
);
}
}
extern
"C"
long
wqwait
(
void
);
static
void
__attribute__
((
used
))
initworker
(
void
)
{
int
id
;
forkt_setup
(
0
);
id
=
nextid
++
;
if
(
id
>=
NCPU
)
die
(
"initworker: to man IDs"
);
pthread_setspecific
(
idkey
,
(
void
*
)(
u64
)
id
);
while
(
1
)
{
if
(
!
wq_trywork
())
assert
(
wqwait
()
==
0
);
}
}
DEFINE_XV6_ADDRNOTE
(
xnote
,
XV6_ADDR_ID_WQ
,
&
initworker
);
static
inline
void
wqarch_init
(
void
)
{
if
(
pthread_key_create
(
&
idkey
,
0
))
die
(
"wqarch_init: pthread_key_create"
);
int
id
=
nextid
++
;
pthread_setspecific
(
idkey
,
(
void
*
)(
u64
)
id
);
}
#define xprintf printf
#define xprintf printf
#define pushcli()
#define pushcli()
#define popcli()
#define popcli()
...
...
kernel/Makefrag
浏览文件 @
d5bf5447
...
@@ -47,7 +47,8 @@ OBJS = \
...
@@ -47,7 +47,8 @@ OBJS = \
trap.o \
trap.o \
uaccess.o \
uaccess.o \
trapasm.o \
trapasm.o \
wq.o \
wqkern.o \
wqlib.o \
script.o \
script.o \
zalloc.o \
zalloc.o \
incbin.o
incbin.o
...
...
kernel/wqkern.cc
0 → 100644
浏览文件 @
d5bf5447
#include "types.h"
#include "kernel.hh"
#include "spinlock.h"
#include "amd64.h"
#include "cpu.hh"
#include "kalloc.hh"
#include "wq.hh"
static
wq
*
wq_
;
size_t
wq_size
(
void
)
{
return
sizeof
(
wq
);
}
int
wq_push
(
work
*
w
)
{
return
wq_
->
push
(
w
,
mycpuid
());
}
int
wq_pushto
(
work
*
w
,
int
tcpuid
)
{
return
wq_
->
push
(
w
,
tcpuid
);
}
int
wq_trywork
(
void
)
{
return
wq_
->
trywork
();
}
void
wq_dump
(
void
)
{
return
wq_
->
dump
();
}
void
initwq
(
void
)
{
wq_
=
new
wq
();
}
lib/Makefrag
浏览文件 @
d5bf5447
...
@@ -2,7 +2,7 @@ $(O)/lib/%.o: CFLAGS:=$(CFLAGS) -DXV6_USER
...
@@ -2,7 +2,7 @@ $(O)/lib/%.o: CFLAGS:=$(CFLAGS) -DXV6_USER
$(O)/lib/%.o: CXXFLAGS:=$(CXXFLAGS) -DXV6_USER
$(O)/lib/%.o: CXXFLAGS:=$(CXXFLAGS) -DXV6_USER
ULIB = ulib.o usys.o printf.o umalloc.o uthread.o fmt.o stream.o ipc.o \
ULIB = ulib.o usys.o printf.o umalloc.o uthread.o fmt.o stream.o ipc.o \
threads.o crt.o wq.o perf.o wqalloc.o
threads.o crt.o wq
lib.o wquser
.o perf.o wqalloc.o
ULIB := $(addprefix $(O)/lib/, $(ULIB))
ULIB := $(addprefix $(O)/lib/, $(ULIB))
.PRECIOUS: $(O)/lib/%.o
.PRECIOUS: $(O)/lib/%.o
...
...
lib/wq.cc
→
lib/wq
lib
.cc
浏览文件 @
d5bf5447
...
@@ -5,49 +5,11 @@
...
@@ -5,49 +5,11 @@
#else
#else
#include "wquser.hh"
#include "wquser.hh"
#endif
#endif
#include "percpu.hh"
#include "wq.hh"
#define NSLOTS (1 << WQSHIFT)
enum
{
wq_steal_others
=
1
};
enum
{
wq_steal_others
=
1
};
class
wq
{
#if 0
public
:
wq
();
int
push
(
work
*
w
,
int
tcpuid
);
int
trywork
();
void
dump
();
static
void
*
operator
new
(
unsigned
long
);
private
:
work
*
steal
(
int
c
);
work
*
pop
(
int
c
);
void
inclen
(
int
c
);
void
declen
(
int
c
);
struct
wqueue
{
work
*
w
[
NSLOTS
];
volatile
int
head
__mpalign__
;
volatile
int
tail
;
wqlock_t
lock
;
};
struct
stat
{
u64
push
;
u64
full
;
u64
pop
;
u64
steal
;
};
percpu
<
wqueue
>
q_
;
percpu
<
stat
>
stat_
;
#if defined(XV6_USER)
uwq_ipcbuf
*
ipc_
;
#endif
};
static wq *wq_;
static wq *wq_;
size_t
size_t
...
@@ -86,6 +48,8 @@ initwq(void)
...
@@ -86,6 +48,8 @@ initwq(void)
wq_ = new wq();
wq_ = new wq();
wqarch_init();
wqarch_init();
}
}
#endif
//
//
// wq
// wq
...
...
lib/wquser.cc
0 → 100644
浏览文件 @
d5bf5447
#include "types.h"
#include "user.h"
#include "uwq.hh"
#include "wq.hh"
#include "atomic.hh"
#include "pthread.h"
#include "elf.hh"
static
pthread_key_t
idkey
;
static
std
::
atomic
<
int
>
nextid
;
static
wq
*
wq_
;
extern
"C"
long
wqwait
(
void
);
static
void
__attribute__
((
used
))
initworker
(
void
)
{
int
id
;
forkt_setup
(
0
);
id
=
nextid
++
;
if
(
id
>=
NCPU
)
die
(
"initworker: to man IDs"
);
pthread_setspecific
(
idkey
,
(
void
*
)(
u64
)
id
);
while
(
1
)
{
if
(
!
wq_trywork
())
assert
(
wqwait
()
==
0
);
}
}
DEFINE_XV6_ADDRNOTE
(
xnote
,
XV6_ADDR_ID_WQ
,
&
initworker
);
static
inline
void
wqarch_init
(
void
)
{
if
(
pthread_key_create
(
&
idkey
,
0
))
die
(
"wqarch_init: pthread_key_create"
);
int
id
=
nextid
++
;
pthread_setspecific
(
idkey
,
(
void
*
)(
u64
)
id
);
}
int
mycpuid
(
void
)
{
return
(
int
)(
u64
)
pthread_getspecific
(
idkey
);
}
size_t
wq_size
(
void
)
{
return
sizeof
(
wq
);
}
int
wq_push
(
work
*
w
)
{
return
wq_
->
push
(
w
,
mycpuid
());
}
int
wq_pushto
(
work
*
w
,
int
tcpuid
)
{
return
wq_
->
push
(
w
,
tcpuid
);
}
int
wq_trywork
(
void
)
{
return
wq_
->
trywork
();
}
void
wq_dump
(
void
)
{
return
wq_
->
dump
();
}
void
initwq
(
void
)
{
wq_
=
new
wq
();
wqarch_init
();
}
param.h
浏览文件 @
d5bf5447
#pragma once
#pragma once
#define DEBUG
1
#define DEBUG
0
#define NPROC 64 // maximum number of processes
#define NPROC 64 // maximum number of processes
#define KSTACKSIZE 8192 // size of per-process kernel stack
#define KSTACKSIZE 8192 // size of per-process kernel stack
#define NOFILE 64 // open files per process
#define NOFILE 64 // open files per process
...
...
user/wqlinux.hh
浏览文件 @
d5bf5447
...
@@ -9,8 +9,6 @@
...
@@ -9,8 +9,6 @@
static
__thread
int
myid_
;
static
__thread
int
myid_
;
typedef
pthread_spinlock_t
wqlock_t
;
int
int
mycpuid
(
void
)
mycpuid
(
void
)
{
{
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论