Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
9c319a62
提交
9c319a62
2月 26, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scopedperf support
上级
6fdb1a06
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
55 行增加
和
7 行删除
+55
-7
cpputil.hh
include/cpputil.hh
+25
-7
kernel.hh
include/kernel.hh
+1
-0
scopedperf.hh
include/scopedperf.hh
+0
-0
sperf.hh
include/sperf.hh
+5
-0
Makefrag
kernel/Makefrag
+1
-0
console.cc
kernel/console.cc
+4
-0
cpprt.cc
kernel/cpprt.cc
+1
-0
main.cc
kernel/main.cc
+1
-0
sperf.cc
kernel/sperf.cc
+17
-0
没有找到文件。
include/cpputil.hh
浏览文件 @
9c319a62
...
@@ -65,26 +65,36 @@ namespace std {
...
@@ -65,26 +65,36 @@ namespace std {
return
static_cast
<
typename
remove_reference
<
T
>::
type
&&>
(
a
);
return
static_cast
<
typename
remove_reference
<
T
>::
type
&&>
(
a
);
}
}
class
ios_base
{};
struct
ostream
{
int
next_width
;
};
class
ostream
:
public
ios_base
{};
extern
ostream
cout
;
extern
ostream
cout
;
static
inline
static
inline
ostream
&
operator
<<
(
ostream
&
s
,
const
char
*
str
)
{
ostream
&
operator
<<
(
ostream
&
s
,
const
char
*
str
)
{
if
(
!
str
)
str
=
"(null)"
;
int
len
=
strlen
(
str
);
cprintf
(
"%s"
,
str
);
cprintf
(
"%s"
,
str
);
while
(
len
<
s
.
next_width
)
{
cprintf
(
" "
);
len
++
;
}
s
.
next_width
=
0
;
return
s
;
return
s
;
}
}
static
inline
static
inline
ostream
&
operator
<<
(
ostream
&
s
,
u32
v
)
{
ostream
&
operator
<<
(
ostream
&
s
,
u32
v
)
{
cprintf
(
"%d"
,
v
);
char
buf
[
32
];
return
s
;
snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
v
);
return
s
<<
buf
;
}
}
static
inline
static
inline
ostream
&
operator
<<
(
ostream
&
s
,
u64
v
)
{
ostream
&
operator
<<
(
ostream
&
s
,
u64
v
)
{
cprintf
(
"%ld"
,
v
);
char
buf
[
32
];
return
s
;
snprintf
(
buf
,
sizeof
(
buf
),
"%ld"
,
v
);
return
s
<<
buf
;
}
}
static
inline
static
inline
...
@@ -94,7 +104,15 @@ namespace std {
...
@@ -94,7 +104,15 @@ namespace std {
static
inline
ostream
&
endl
(
ostream
&
s
)
{
s
<<
"
\n
"
;
return
s
;
}
static
inline
ostream
&
endl
(
ostream
&
s
)
{
s
<<
"
\n
"
;
return
s
;
}
static
inline
ostream
&
left
(
ostream
&
s
)
{
return
s
;
}
static
inline
ostream
&
left
(
ostream
&
s
)
{
return
s
;
}
static
inline
const
char
*
setw
(
int
n
)
{
return
""
;
}
struct
ssetw
{
int
_n
;
};
static
inline
ssetw
setw
(
int
n
)
{
return
{
n
};
}
static
inline
ostream
&
operator
<<
(
ostream
&
s
,
const
ssetw
&
sw
)
{
s
.
next_width
=
sw
.
_n
;
return
s
;
}
}
}
/* C++ runtime */
/* C++ runtime */
...
...
include/kernel.hh
浏览文件 @
9c319a62
...
@@ -307,6 +307,7 @@ void initnet(void);
...
@@ -307,6 +307,7 @@ void initnet(void);
void
initsched
(
void
);
void
initsched
(
void
);
void
initlockstat
(
void
);
void
initlockstat
(
void
);
void
initwq
(
void
);
void
initwq
(
void
);
void
initsperf
(
void
);
// other exported/imported functions
// other exported/imported functions
void
cmain
(
u64
mbmagic
,
u64
mbaddr
);
void
cmain
(
u64
mbmagic
,
u64
mbaddr
);
...
...
include/scopedperf.hh
0 → 100644
浏览文件 @
9c319a62
差异被折叠。
点击展开。
include/sperf.hh
0 → 100644
浏览文件 @
9c319a62
#pragma once
#include "scopedperf.hh"
extern
scopedperf
::
ctrgroup_chain
<
scopedperf
::
tsc_ctr
>
*
perfgroup
;
kernel/Makefrag
浏览文件 @
9c319a62
...
@@ -34,6 +34,7 @@ OBJS = \
...
@@ -34,6 +34,7 @@ OBJS = \
rnd.o \
rnd.o \
sampler.o \
sampler.o \
sched.o \
sched.o \
sperf.o \
spinlock.o \
spinlock.o \
swtch.o \
swtch.o \
string.o \
string.o \
...
...
kernel/console.cc
浏览文件 @
9c319a62
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include <stdarg.h>
#include <stdarg.h>
#include "fmt.hh"
#include "fmt.hh"
#include <stddef.h>
#include <stddef.h>
#include "sperf.hh"
#define BACKSPACE 0x100
#define BACKSPACE 0x100
...
@@ -285,6 +286,9 @@ consoleintr(int (*getc)(void))
...
@@ -285,6 +286,9 @@ consoleintr(int (*getc)(void))
case
C
(
'F'
):
// kmem stats
case
C
(
'F'
):
// kmem stats
kmemprint
();
kmemprint
();
break
;
break
;
case
C
(
'Y'
):
// scopedperf stats
scopedperf
::
perfsum_base
::
printall
();
break
;
default:
default:
if
(
c
!=
0
&&
input
.
e
-
input
.
r
<
INPUT_BUF
){
if
(
c
!=
0
&&
input
.
e
-
input
.
r
<
INPUT_BUF
){
c
=
(
c
==
'\r'
)
?
'\n'
:
c
;
c
=
(
c
==
'\r'
)
?
'\n'
:
c
;
...
...
kernel/cpprt.cc
浏览文件 @
9c319a62
...
@@ -63,6 +63,7 @@ __cxa_atexit(void (*f)(void*), void *p, void *d)
...
@@ -63,6 +63,7 @@ __cxa_atexit(void (*f)(void*), void *p, void *d)
}
}
void
*
__dso_handle
;
void
*
__dso_handle
;
std
::
ostream
std
::
cout
;
namespace
std
{
namespace
std
{
...
...
kernel/main.cc
浏览文件 @
9c319a62
...
@@ -95,6 +95,7 @@ cmain(u64 mbmagic, u64 mbaddr)
...
@@ -95,6 +95,7 @@ cmain(u64 mbmagic, u64 mbaddr)
initpci
();
initpci
();
initnet
();
initnet
();
initidle
();
initidle
();
initsperf
();
if
(
VERBOSE
)
if
(
VERBOSE
)
cprintf
(
"ncpu %d %lu MHz
\n
"
,
ncpu
,
cpuhz
/
1000000
);
cprintf
(
"ncpu %d %lu MHz
\n
"
,
ncpu
,
cpuhz
/
1000000
);
...
...
kernel/sperf.cc
0 → 100644
浏览文件 @
9c319a62
#include "types.h"
#include "kernel.hh"
#include "cpu.hh"
#include "cpputil.hh"
#include "spinlock.h"
#include "sperf.hh"
using
namespace
scopedperf
;
ctrgroup_chain
<
tsc_ctr
>
*
perfgroup
;
void
initsperf
()
{
static
tsc_ctr
tsc
;
perfgroup
=
new
ctrgroup_chain
<
tsc_ctr
>
(
&
tsc
);
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论