Commit 15a7644956c5265ed3e4d2817a9eca993d0b64fa
1 parent
8dd69b8f
better SMP scheduling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1649 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
17 additions
and
25 deletions
vl.c
| ... | ... | @@ -3682,25 +3682,6 @@ void main_loop_wait(int timeout) |
| 3682 | 3682 | |
| 3683 | 3683 | static CPUState *cur_cpu; |
| 3684 | 3684 | |
| 3685 | -static CPUState *find_next_cpu(void) | |
| 3686 | -{ | |
| 3687 | - CPUState *env; | |
| 3688 | - env = cur_cpu; | |
| 3689 | - for(;;) { | |
| 3690 | - /* get next cpu */ | |
| 3691 | - env = env->next_cpu; | |
| 3692 | - if (!env) | |
| 3693 | - env = first_cpu; | |
| 3694 | - if (!env->cpu_halted) | |
| 3695 | - break; | |
| 3696 | - /* all CPUs are halted ? */ | |
| 3697 | - if (env == cur_cpu) | |
| 3698 | - return NULL; | |
| 3699 | - } | |
| 3700 | - cur_cpu = env; | |
| 3701 | - return env; | |
| 3702 | -} | |
| 3703 | - | |
| 3704 | 3685 | int main_loop(void) |
| 3705 | 3686 | { |
| 3706 | 3687 | int ret, timeout; |
| ... | ... | @@ -3709,13 +3690,24 @@ int main_loop(void) |
| 3709 | 3690 | cur_cpu = first_cpu; |
| 3710 | 3691 | for(;;) { |
| 3711 | 3692 | if (vm_running) { |
| 3712 | - /* find next cpu to run */ | |
| 3713 | - /* XXX: handle HLT correctly */ | |
| 3714 | - env = find_next_cpu(); | |
| 3715 | - if (!env) | |
| 3716 | - ret = EXCP_HLT; | |
| 3717 | - else | |
| 3693 | + | |
| 3694 | + env = cur_cpu; | |
| 3695 | + for(;;) { | |
| 3696 | + /* get next cpu */ | |
| 3697 | + env = env->next_cpu; | |
| 3698 | + if (!env) | |
| 3699 | + env = first_cpu; | |
| 3718 | 3700 | 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 | + | |
| 3719 | 3711 | if (shutdown_requested) { |
| 3720 | 3712 | ret = EXCP_INTERRUPT; |
| 3721 | 3713 | break; | ... | ... |