Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
c9fa90f7
提交
c9fa90f7
2月 01, 2017
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A tiny bit of clean up (e.g., move code searching cpu array from lapic.c into
mycpu() in proc.c.
上级
2e2d14c2
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
17 行增加
和
17 行删除
+17
-17
console.c
console.c
+1
-1
defs.h
defs.h
+1
-1
lapic.c
lapic.c
+2
-13
proc.c
proc.c
+13
-2
没有找到文件。
console.c
浏览文件 @
c9fa90f7
...
@@ -112,7 +112,7 @@ panic(char *s)
...
@@ -112,7 +112,7 @@ panic(char *s)
cli
();
cli
();
cons
.
locking
=
0
;
cons
.
locking
=
0
;
// use lapiccpunum so that we can call panic from mycpu()
// use lapiccpunum so that we can call panic from mycpu()
cprintf
(
"
cpu %d: panic: "
,
lapiccpunum
());
cprintf
(
"
lapicid %d: panic: "
,
lapicid
());
cprintf
(
s
);
cprintf
(
s
);
cprintf
(
"
\n
"
);
cprintf
(
"
\n
"
);
getcallerpcs
(
&
s
,
pcs
);
getcallerpcs
(
&
s
,
pcs
);
...
...
defs.h
浏览文件 @
c9fa90f7
...
@@ -74,7 +74,7 @@ void kbdintr(void);
...
@@ -74,7 +74,7 @@ void kbdintr(void);
// lapic.c
// lapic.c
void
cmostime
(
struct
rtcdate
*
r
);
void
cmostime
(
struct
rtcdate
*
r
);
int
lapic
cpunum
(
void
);
int
lapic
id
(
void
);
extern
volatile
uint
*
lapic
;
extern
volatile
uint
*
lapic
;
void
lapiceoi
(
void
);
void
lapiceoi
(
void
);
void
lapicinit
(
void
);
void
lapicinit
(
void
);
...
...
lapic.c
浏览文件 @
c9fa90f7
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
#include "traps.h"
#include "traps.h"
#include "mmu.h"
#include "mmu.h"
#include "x86.h"
#include "x86.h"
#include "proc.h" // ncpu
// Local APIC registers, divided by 4 for use as uint[] indices.
// Local APIC registers, divided by 4 for use as uint[] indices.
#define ID (0x0020/4) // ID
#define ID (0x0020/4) // ID
...
@@ -98,22 +97,12 @@ lapicinit(void)
...
@@ -98,22 +97,12 @@ lapicinit(void)
lapicw
(
TPR
,
0
);
lapicw
(
TPR
,
0
);
}
}
// Should be called with interrupts disabled: the calling thread shouldn't be
// rescheduled between reading lapic[ID] and checking against cpu array.
int
int
lapic
cpunum
(
void
)
lapic
id
(
void
)
{
{
int
apicid
,
i
;
if
(
!
lapic
)
if
(
!
lapic
)
return
0
;
return
0
;
return
lapic
[
ID
]
>>
24
;
apicid
=
lapic
[
ID
]
>>
24
;
for
(
i
=
0
;
i
<
ncpu
;
++
i
)
{
if
(
cpus
[
i
].
apicid
==
apicid
)
return
i
;
}
panic
(
"unknown apicid
\n
"
);
}
}
// Acknowledge interrupt.
// Acknowledge interrupt.
...
...
proc.c
浏览文件 @
c9fa90f7
...
@@ -32,13 +32,24 @@ cpuid() {
...
@@ -32,13 +32,24 @@ cpuid() {
return
mycpu
()
-
cpus
;
return
mycpu
()
-
cpus
;
}
}
// Must be called with interrupts disabled
// Must be called with interrupts disabled to avoid the caller being rescheduled
// between reading lapicid and running through the loop.
struct
cpu
*
struct
cpu
*
mycpu
(
void
)
mycpu
(
void
)
{
{
int
apicid
,
i
;
if
(
readeflags
()
&
FL_IF
)
if
(
readeflags
()
&
FL_IF
)
panic
(
"mycpu called with interrupts enabled
\n
"
);
panic
(
"mycpu called with interrupts enabled
\n
"
);
return
&
cpus
[
lapiccpunum
()];
apicid
=
lapicid
();
// APIC IDs are not guaranteed to be contiguous. Maybe we should have
// a reverse map, or reserve a register to store &cpus[i].
for
(
i
=
0
;
i
<
ncpu
;
++
i
)
{
if
(
cpus
[
i
].
apicid
==
apicid
)
return
&
cpus
[
i
];
}
panic
(
"unknown apicid
\n
"
);
}
}
// Disable interrupts so that we are not rescheduled
// Disable interrupts so that we are not rescheduled
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论