Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
814e612e
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
814e612e
编写于
5月 02, 2012
作者:
A
Andreas Färber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cpu: Move thread field into CPUState
Signed-off-by:
N
Andreas Färber
<
afaerber@suse.de
>
上级
bcba2a72
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
18 deletion
+24
-18
cpu-defs.h
cpu-defs.h
+0
-1
cpus.c
cpus.c
+23
-17
include/qemu/cpu.h
include/qemu/cpu.h
+1
-0
未找到文件。
cpu-defs.h
浏览文件 @
814e612e
...
...
@@ -208,7 +208,6 @@ typedef struct CPUWatchpoint {
uint32_t created; \
uint32_t stop;
/* Stop request */
\
uint32_t stopped;
/* Artificially stopped */
\
struct QemuThread *thread; \
struct QemuCond *halt_cond; \
int thread_kicked; \
struct qemu_work_item *queued_work_first, *queued_work_last; \
...
...
cpus.c
浏览文件 @
814e612e
...
...
@@ -728,10 +728,11 @@ static void qemu_kvm_wait_io_event(CPUArchState *env)
static
void
*
qemu_kvm_cpu_thread_fn
(
void
*
arg
)
{
CPUArchState
*
env
=
arg
;
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
int
r
;
qemu_mutex_lock
(
&
qemu_global_mutex
);
qemu_thread_get_self
(
env
->
thread
);
qemu_thread_get_self
(
cpu
->
thread
);
env
->
thread_id
=
qemu_get_thread_id
();
cpu_single_env
=
env
;
...
...
@@ -767,11 +768,12 @@ static void *qemu_dummy_cpu_thread_fn(void *arg)
exit
(
1
);
#else
CPUArchState
*
env
=
arg
;
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
sigset_t
waitset
;
int
r
;
qemu_mutex_lock_iothread
();
qemu_thread_get_self
(
env
->
thread
);
qemu_thread_get_self
(
cpu
->
thread
);
env
->
thread_id
=
qemu_get_thread_id
();
sigemptyset
(
&
waitset
);
...
...
@@ -807,9 +809,10 @@ static void tcg_exec_all(void);
static
void
*
qemu_tcg_cpu_thread_fn
(
void
*
arg
)
{
CPUArchState
*
env
=
arg
;
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
qemu_tcg_init_cpu_signals
();
qemu_thread_get_self
(
env
->
thread
);
qemu_thread_get_self
(
cpu
->
thread
);
/* signal CPU creation */
qemu_mutex_lock
(
&
qemu_global_mutex
);
...
...
@@ -842,17 +845,17 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
static
void
qemu_cpu_kick_thread
(
CPUArchState
*
env
)
{
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
#ifndef _WIN32
int
err
;
err
=
pthread_kill
(
env
->
thread
->
thread
,
SIG_IPI
);
err
=
pthread_kill
(
cpu
->
thread
->
thread
,
SIG_IPI
);
if
(
err
)
{
fprintf
(
stderr
,
"qemu:%s: %s"
,
__func__
,
strerror
(
err
));
exit
(
1
);
}
#else
/* _WIN32 */
if
(
!
qemu_cpu_is_self
(
env
))
{
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
SuspendThread
(
cpu
->
hThread
);
cpu_signal
(
0
);
ResumeThread
(
cpu
->
hThread
);
...
...
@@ -888,8 +891,9 @@ void qemu_cpu_kick_self(void)
int
qemu_cpu_is_self
(
void
*
_env
)
{
CPUArchState
*
env
=
_env
;
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
return
qemu_thread_is_self
(
env
->
thread
);
return
qemu_thread_is_self
(
cpu
->
thread
);
}
void
qemu_mutex_lock_iothread
(
void
)
...
...
@@ -975,37 +979,37 @@ void resume_all_vcpus(void)
static
void
qemu_tcg_init_vcpu
(
void
*
_env
)
{
CPUArchState
*
env
=
_env
;
#ifdef _WIN32
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
#endif
/* share a single thread for all cpus with TCG */
if
(
!
tcg_cpu_thread
)
{
env
->
thread
=
g_malloc0
(
sizeof
(
QemuThread
));
cpu
->
thread
=
g_malloc0
(
sizeof
(
QemuThread
));
env
->
halt_cond
=
g_malloc0
(
sizeof
(
QemuCond
));
qemu_cond_init
(
env
->
halt_cond
);
tcg_halt_cond
=
env
->
halt_cond
;
qemu_thread_create
(
env
->
thread
,
qemu_tcg_cpu_thread_fn
,
env
,
qemu_thread_create
(
cpu
->
thread
,
qemu_tcg_cpu_thread_fn
,
env
,
QEMU_THREAD_JOINABLE
);
#ifdef _WIN32
cpu
->
hThread
=
qemu_thread_get_handle
(
env
->
thread
);
cpu
->
hThread
=
qemu_thread_get_handle
(
cpu
->
thread
);
#endif
while
(
env
->
created
==
0
)
{
qemu_cond_wait
(
&
qemu_cpu_cond
,
&
qemu_global_mutex
);
}
tcg_cpu_thread
=
env
->
thread
;
tcg_cpu_thread
=
cpu
->
thread
;
}
else
{
env
->
thread
=
tcg_cpu_thread
;
cpu
->
thread
=
tcg_cpu_thread
;
env
->
halt_cond
=
tcg_halt_cond
;
}
}
static
void
qemu_kvm_start_vcpu
(
CPUArchState
*
env
)
{
env
->
thread
=
g_malloc0
(
sizeof
(
QemuThread
));
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
cpu
->
thread
=
g_malloc0
(
sizeof
(
QemuThread
));
env
->
halt_cond
=
g_malloc0
(
sizeof
(
QemuCond
));
qemu_cond_init
(
env
->
halt_cond
);
qemu_thread_create
(
env
->
thread
,
qemu_kvm_cpu_thread_fn
,
env
,
qemu_thread_create
(
cpu
->
thread
,
qemu_kvm_cpu_thread_fn
,
env
,
QEMU_THREAD_JOINABLE
);
while
(
env
->
created
==
0
)
{
qemu_cond_wait
(
&
qemu_cpu_cond
,
&
qemu_global_mutex
);
...
...
@@ -1014,10 +1018,12 @@ static void qemu_kvm_start_vcpu(CPUArchState *env)
static
void
qemu_dummy_start_vcpu
(
CPUArchState
*
env
)
{
env
->
thread
=
g_malloc0
(
sizeof
(
QemuThread
));
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
cpu
->
thread
=
g_malloc0
(
sizeof
(
QemuThread
));
env
->
halt_cond
=
g_malloc0
(
sizeof
(
QemuCond
));
qemu_cond_init
(
env
->
halt_cond
);
qemu_thread_create
(
env
->
thread
,
qemu_dummy_cpu_thread_fn
,
env
,
qemu_thread_create
(
cpu
->
thread
,
qemu_dummy_cpu_thread_fn
,
env
,
QEMU_THREAD_JOINABLE
);
while
(
env
->
created
==
0
)
{
qemu_cond_wait
(
&
qemu_cpu_cond
,
&
qemu_global_mutex
);
...
...
include/qemu/cpu.h
浏览文件 @
814e612e
...
...
@@ -62,6 +62,7 @@ struct CPUState {
Object
parent_obj
;
/*< public >*/
struct
QemuThread
*
thread
;
#ifdef _WIN32
HANDLE
hThread
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录