x86: syscall: implementation of exit_group
authorSeverin Wischmann ext:(%2C%20Ioannis%20Ilkos%20%3Cioannis.ilkos09%40imperial.ac.uk%3E) <wiseveri@student.ethz.ch>
Mon, 20 Oct 2014 21:43:48 +0000 (16:43 -0500)
committerSeverin Wischmann ext:(%2C%20Ioannis%20Ilkos%20%3Cioannis.ilkos09%40imperial.ac.uk%3E) <wiseveri@student.ethz.ch>
Mon, 20 Oct 2014 21:43:48 +0000 (16:43 -0500)
On exit_group syscall, we used to exit the simulator.  But now we will only
halt the execution of threads that belong to the group.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

src/sim/syscall_emul.cc

index 13ea784e54f4de04f576bd1e2589af40d928246a..d8df891dde4a5c223953b1b5cc9974d6eb5f2db0 100644 (file)
@@ -135,11 +135,17 @@ SyscallReturn
 exitGroupFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
               ThreadContext *tc)
 {
-    // really should just halt all thread contexts belonging to this
-    // process in case there's another process running...
-    int index = 0;
-    exitSimLoop("target called exit()",
-                process->getSyscallArg(tc, index) & 0xff);
+    // halt all threads belonging to this process
+    for (auto i: process->contextIds) {
+        process->system->getThreadContext(i)->halt();
+    }
+
+    if (!process->system->numRunningContexts()) {
+        // all threads belonged to this process... exit simulator
+        int index = 0;
+        exitSimLoop("target called exit()",
+                    process->getSyscallArg(tc, index) & 0xff);
+    }
 
     return 1;
 }