strip out per cpu thread code
This commit is contained in:
48
qemu/cpus.c
48
qemu/cpus.c
@@ -55,28 +55,10 @@ bool cpu_is_stopped(CPUState *cpu)
|
||||
|
||||
void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)
|
||||
{
|
||||
if (qemu_cpu_is_self(cpu)) {
|
||||
func(data);
|
||||
return;
|
||||
}
|
||||
func(data);
|
||||
return;
|
||||
}
|
||||
|
||||
// send halt_cond/tcg_halt_cond to @cpu
|
||||
bool qemu_cpu_is_self(CPUState *cpu)
|
||||
{
|
||||
return qemu_thread_is_self(cpu->thread);
|
||||
}
|
||||
|
||||
void pause_all_vcpus(struct uc_struct *uc)
|
||||
{
|
||||
CPUState *cpu;
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
qemu_thread_join(cpu->thread); // qq: fix qemu_thread_join() to work for instance
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int resume_all_vcpus(struct uc_struct *uc)
|
||||
{
|
||||
CPUState *cpu;
|
||||
@@ -112,7 +94,6 @@ int qemu_init_vcpu(CPUState *cpu)
|
||||
cpu->nr_cores = smp_cores;
|
||||
cpu->nr_threads = smp_threads;
|
||||
cpu->stopped = true;
|
||||
cpu->uc->tcg_cpu_thread = NULL;
|
||||
|
||||
if (tcg_enabled(cpu->uc))
|
||||
return qemu_tcg_init_vcpu(cpu);
|
||||
@@ -129,7 +110,6 @@ static void *qemu_tcg_cpu_loop(struct uc_struct *uc)
|
||||
|
||||
qemu_mutex_lock(&uc->qemu_global_mutex);
|
||||
CPU_FOREACH(cpu) {
|
||||
cpu->thread_id = qemu_get_thread_id();
|
||||
cpu->created = true;
|
||||
}
|
||||
qemu_cond_signal(&uc->qemu_cpu_cond);
|
||||
@@ -140,7 +120,6 @@ static void *qemu_tcg_cpu_loop(struct uc_struct *uc)
|
||||
}
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
cpu->thread_id = 0;
|
||||
cpu->created = false;
|
||||
}
|
||||
|
||||
@@ -151,33 +130,16 @@ static void *qemu_tcg_cpu_loop(struct uc_struct *uc)
|
||||
|
||||
|
||||
|
||||
/* For temporary buffers for forming a name */
|
||||
#define VCPU_THREAD_NAME_SIZE 16
|
||||
|
||||
static int qemu_tcg_init_vcpu(CPUState *cpu)
|
||||
{
|
||||
struct uc_struct *uc = cpu->uc;
|
||||
char thread_name[VCPU_THREAD_NAME_SIZE];
|
||||
|
||||
tcg_cpu_address_space_init(cpu, cpu->as);
|
||||
|
||||
/* share a single thread for all cpus with TCG */
|
||||
if (!uc->tcg_cpu_thread) {
|
||||
cpu->thread = g_malloc0(sizeof(QemuThread));
|
||||
cpu->halt_cond = g_malloc0(sizeof(QemuCond));
|
||||
qemu_cond_init(cpu->halt_cond);
|
||||
uc->tcg_halt_cond = cpu->halt_cond;
|
||||
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG",
|
||||
cpu->cpu_index);
|
||||
qemu_thread_get_self(uc, cpu->thread);
|
||||
#ifdef _WIN32
|
||||
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
||||
#endif
|
||||
uc->tcg_cpu_thread = cpu->thread;
|
||||
} else {
|
||||
cpu->thread = uc->tcg_cpu_thread;
|
||||
cpu->halt_cond = uc->tcg_halt_cond;
|
||||
}
|
||||
cpu->halt_cond = g_malloc0(sizeof(QemuCond));
|
||||
qemu_cond_init(cpu->halt_cond);
|
||||
uc->tcg_halt_cond = cpu->halt_cond;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user