Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
7e0cc8e3
提交
7e0cc8e3
9月 02, 2009
创建
作者:
Russ Cox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
another attempt at cpu-local variables.
this time do it ourselves instead of piggybacking on TLS. add -fno-pic to Makefile; pic code breaks our fake TLS.
上级
374362c5
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
16 行增加
和
18 行删除
+16
-18
Makefile
Makefile
+5
-5
main.c
main.c
+1
-3
proc.c
proc.c
+1
-2
proc.h
proc.h
+9
-8
没有找到文件。
Makefile
浏览文件 @
7e0cc8e3
...
...
@@ -37,7 +37,7 @@ AS = $(TOOLPREFIX)gas
LD
=
$(TOOLPREFIX)
ld
OBJCOPY
=
$(TOOLPREFIX)
objcopy
OBJDUMP
=
$(TOOLPREFIX)
objdump
CFLAGS
=
-fno-builtin
-fno-strict-aliasing
-O2
-Wall
-MD
-ggdb
-m32
CFLAGS
=
-fno-
pic
-static
-fno-
builtin
-fno-strict-aliasing
-O2
-Wall
-MD
-ggdb
-m32
CFLAGS
+=
$(
shell
$(CC)
-fno-stack-protector
-E
-x
c /dev/null
>
/dev/null 2>&1
&&
echo
-fno-stack-protector
)
ASFLAGS
=
-m32
# FreeBSD ld wants ``elf_i386_fbsd''
...
...
@@ -49,8 +49,8 @@ xv6.img: bootblock kernel fs.img
dd
if
=
kernel
of
=
xv6.img
seek
=
1
conv
=
notrunc
bootblock
:
bootasm.S bootmain.c
$(CC)
$(CFLAGS)
-O
-nostdinc
-I
.
-c
bootmain.c
$(CC)
$(CFLAGS)
-nostdinc
-I
.
-c
bootasm.S
$(CC)
$(CFLAGS)
-
fno-pic
-
O
-nostdinc
-I
.
-c
bootmain.c
$(CC)
$(CFLAGS)
-
fno-pic
-
nostdinc
-I
.
-c
bootasm.S
$(LD)
$(LDFLAGS)
-N
-e
start
-Ttext
0x7C00
-o
bootblock.o bootasm.o bootmain.o
$(OBJDUMP)
-S
bootblock.o
>
bootblock.asm
$(OBJCOPY)
-S
-O
binary
-j
.text bootblock.o bootblock
...
...
@@ -93,7 +93,7 @@ _forktest: forktest.o $(ULIB)
$(OBJDUMP)
-S
_forktest
>
forktest.asm
mkfs
:
mkfs.c fs.h
gcc
$(CFLAGS)
-Wall
-o
mkfs mkfs.c
gcc
-Wall
-o
mkfs mkfs.c
UPROGS
=
\
_cat
\
...
...
@@ -139,7 +139,7 @@ bochs : fs.img xv6.img
bochs
-q
qemu
:
fs.img xv6.img
qemu
-parallel
stdio
-hdb
fs.img xv6.img
qemu
-parallel
stdio
-
smp
2
-
hdb
fs.img xv6.img
qemutty
:
fs.img xv6.img
qemu
-nographic
-smp
2
-hdb
fs.img xv6.img
...
...
main.c
浏览文件 @
7e0cc8e3
...
...
@@ -5,9 +5,6 @@
#include "proc.h"
#include "x86.h"
__thread
struct
cpu
*
cpu
;
__thread
struct
proc
*
proc
;
static
void
bootothers
(
void
);
static
void
mpmain
(
void
)
__attribute__
((
noreturn
));
...
...
@@ -22,6 +19,7 @@ main(void)
ioapicinit
();
// another interrupt controller
consoleinit
();
// I/O devices & their interrupts
uartinit
();
// serial port
cprintf
(
"cpus %p cpu %p
\n
"
,
cpus
,
cpu
);
cprintf
(
"
\n
cpu%d: starting xv6
\n\n
"
,
cpu
->
id
);
kinit
();
// physical memory allocator
...
...
proc.c
浏览文件 @
7e0cc8e3
...
...
@@ -70,12 +70,11 @@ ksegment(void)
c
=
&
cpus
[
cpunum
()];
c
->
gdt
[
SEG_KCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0x100000
+
64
*
1024
-
1
,
0
);
c
->
gdt
[
SEG_KDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
0
);
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
tlsstruct
,
0xffffffff
,
0
);
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
8
,
0
);
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
loadfsgs
(
SEG_KCPU
<<
3
);
// Initialize cpu-local storage.
c
->
tlsstruct
=
&
c
->
tlsstruct
;
asm
volatile
(
""
);
// Do not let gcc reorder across this line.
cpu
=
c
;
proc
=
0
;
...
...
proc.h
浏览文件 @
7e0cc8e3
...
...
@@ -59,10 +59,9 @@ struct cpu {
int
ncli
;
// Depth of pushcli nesting.
int
intena
;
// Were interrupts enabled before pushcli?
//
"Thread"-local storage variables
//
Cpu-local storage variables; see below
struct
cpu
*
cpu
;
struct
proc
*
proc
;
void
*
tlsstruct
;
};
extern
struct
cpu
cpus
[
NCPU
];
...
...
@@ -70,9 +69,11 @@ extern int ncpu;
// Per-CPU variables, holding pointers to the
// current cpu and to the current process.
// The __thread prefix tells gcc to refer to them in the segment
// pointed at by gs; the name __thread derives from the use
// of the same mechanism to provide per-thread storage in
// multithreaded user programs.
extern
__thread
struct
cpu
*
cpu
;
// This cpu.
extern
__thread
struct
proc
*
proc
;
// Current process on this cpu.
// The asm suffix tells gcc to use "%gs:0" to refer to cpu
// and "%gs:4" to refer to proc. ksegment sets up the
// %gs segment register so that %gs refers to the memory
// holding those two variables in the local cpu's struct cpu.
// This is similar to how thread-local variables are implemented
// in thread libraries such as Linux pthreads.
extern
struct
cpu
*
cpu
asm
(
"%gs:0"
);
// This cpu.
extern
struct
proc
*
proc
asm
(
"%gs:4"
);
// Current proc on this cpu.
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论