2 * Dummy cpu thread code
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
14 #include "qemu/osdep.h"
16 #include "sysemu/cpus.h"
17 #include "qemu/guest-random.h"
18 #include "qemu/main-loop.h"
19 #include "hw/core/cpu.h"
21 static void *dummy_cpu_thread_fn(void *arg
)
25 rcu_register_thread();
28 qemu_thread_get_self(cpu
->thread
);
29 cpu
->thread_id
= qemu_get_thread_id();
36 sigemptyset(&waitset
);
37 sigaddset(&waitset
, SIG_IPI
);
40 /* signal CPU creation */
41 cpu_thread_signal_created(cpu
);
42 qemu_guest_random_seed_thread_part2(cpu
->random_seed
);
49 r
= sigwait(&waitset
, &sig
);
50 } while (r
== -1 && (errno
== EAGAIN
|| errno
== EINTR
));
56 qemu_sem_wait(&cpu
->sem
);
59 qemu_wait_io_event(cpu
);
60 } while (!cpu
->unplug
);
63 rcu_unregister_thread();
67 void dummy_start_vcpu_thread(CPUState
*cpu
)
69 char thread_name
[VCPU_THREAD_NAME_SIZE
];
71 cpu
->thread
= g_malloc0(sizeof(QemuThread
));
72 cpu
->halt_cond
= g_malloc0(sizeof(QemuCond
));
73 qemu_cond_init(cpu
->halt_cond
);
74 snprintf(thread_name
, VCPU_THREAD_NAME_SIZE
, "CPU %d/DUMMY",
76 qemu_thread_create(cpu
->thread
, thread_name
, dummy_cpu_thread_fn
, cpu
,
77 QEMU_THREAD_JOINABLE
);
79 qemu_sem_init(&cpu
->sem
, 0);