mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
better SMP scheduling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1649 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
8dd69b8f2c
commit
15a7644956
1 changed files with 17 additions and 25 deletions
42
vl.c
42
vl.c
|
@ -3682,25 +3682,6 @@ void main_loop_wait(int timeout)
|
||||||
|
|
||||||
static CPUState *cur_cpu;
|
static CPUState *cur_cpu;
|
||||||
|
|
||||||
static CPUState *find_next_cpu(void)
|
|
||||||
{
|
|
||||||
CPUState *env;
|
|
||||||
env = cur_cpu;
|
|
||||||
for(;;) {
|
|
||||||
/* get next cpu */
|
|
||||||
env = env->next_cpu;
|
|
||||||
if (!env)
|
|
||||||
env = first_cpu;
|
|
||||||
if (!env->cpu_halted)
|
|
||||||
break;
|
|
||||||
/* all CPUs are halted ? */
|
|
||||||
if (env == cur_cpu)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
cur_cpu = env;
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main_loop(void)
|
int main_loop(void)
|
||||||
{
|
{
|
||||||
int ret, timeout;
|
int ret, timeout;
|
||||||
|
@ -3709,13 +3690,24 @@ int main_loop(void)
|
||||||
cur_cpu = first_cpu;
|
cur_cpu = first_cpu;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (vm_running) {
|
if (vm_running) {
|
||||||
/* find next cpu to run */
|
|
||||||
/* XXX: handle HLT correctly */
|
env = cur_cpu;
|
||||||
env = find_next_cpu();
|
for(;;) {
|
||||||
if (!env)
|
/* get next cpu */
|
||||||
ret = EXCP_HLT;
|
env = env->next_cpu;
|
||||||
else
|
if (!env)
|
||||||
|
env = first_cpu;
|
||||||
ret = cpu_exec(env);
|
ret = cpu_exec(env);
|
||||||
|
if (ret != EXCP_HALTED)
|
||||||
|
break;
|
||||||
|
/* all CPUs are halted ? */
|
||||||
|
if (env == cur_cpu) {
|
||||||
|
ret = EXCP_HLT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur_cpu = env;
|
||||||
|
|
||||||
if (shutdown_requested) {
|
if (shutdown_requested) {
|
||||||
ret = EXCP_INTERRUPT;
|
ret = EXCP_INTERRUPT;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue