aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-11-23 21:01:03 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-11-23 21:01:03 +0000
commit15a7644956c5265ed3e4d2817a9eca993d0b64fa (patch)
tree007c6f14208255b401dd75664e6250ddd025d16b
parent8dd69b8f2cba91b7f2bcb3b4e12fbd35574869c1 (diff)
better SMP scheduling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1649 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--vl.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/vl.c b/vl.c
index b946390a13..eaf6a1d681 100644
--- a/vl.c
+++ b/vl.c
@@ -3682,25 +3682,6 @@ void main_loop_wait(int timeout)
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 ret, timeout;
@@ -3709,13 +3690,24 @@ int main_loop(void)
cur_cpu = first_cpu;
for(;;) {
if (vm_running) {
- /* find next cpu to run */
- /* XXX: handle HLT correctly */
- env = find_next_cpu();
- if (!env)
- ret = EXCP_HLT;
- else
+
+ env = cur_cpu;
+ for(;;) {
+ /* get next cpu */
+ env = env->next_cpu;
+ if (!env)
+ env = first_cpu;
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) {
ret = EXCP_INTERRUPT;
break;