3682 |
|
|
3683 |
static CPUState *cur_cpu; |
static CPUState *cur_cpu; |
3684 |
|
|
|
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; |
|
|
} |
|
|
|
|
3685 |
int main_loop(void) |
int main_loop(void) |
3686 |
{ |
{ |
3687 |
int ret, timeout; |
int ret, timeout; |
3690 |
cur_cpu = first_cpu; |
cur_cpu = first_cpu; |
3691 |
for(;;) { |
for(;;) { |
3692 |
if (vm_running) { |
if (vm_running) { |
3693 |
/* find next cpu to run */ |
|
3694 |
/* XXX: handle HLT correctly */ |
env = cur_cpu; |
3695 |
env = find_next_cpu(); |
for(;;) { |
3696 |
if (!env) |
/* get next cpu */ |
3697 |
ret = EXCP_HLT; |
env = env->next_cpu; |
3698 |
else |
if (!env) |
3699 |
|
env = first_cpu; |
3700 |
ret = cpu_exec(env); |
ret = cpu_exec(env); |
3701 |
|
if (ret != EXCP_HALTED) |
3702 |
|
break; |
3703 |
|
/* all CPUs are halted ? */ |
3704 |
|
if (env == cur_cpu) { |
3705 |
|
ret = EXCP_HLT; |
3706 |
|
break; |
3707 |
|
} |
3708 |
|
} |
3709 |
|
cur_cpu = env; |
3710 |
|
|
3711 |
if (shutdown_requested) { |
if (shutdown_requested) { |
3712 |
ret = EXCP_INTERRUPT; |
ret = EXCP_INTERRUPT; |
3713 |
break; |
break; |