diff options
author | Tuan Ta <qtt2@cornell.edu> | 2018-04-02 16:22:50 -0400 |
---|---|---|
committer | Tuan Ta <qtt2@cornell.edu> | 2019-02-08 15:25:30 +0000 |
commit | 42b063ad30324f1459915070226e820aabd54336 (patch) | |
tree | bffc0c5b937bde1c516a2a4c978008e80c19a808 /src/sim/syscall_emul.hh | |
parent | 2eb57c7c3bb762097aa7bdab40cd37ec73996dca (diff) | |
download | gem5-42b063ad30324f1459915070226e820aabd54336.tar.xz |
sim: handle the case when there're not enough HW thread contexts
In SE mode, since there's no OS scheduler, the number of active SW
threads is limited by the number of HW thread contexts. Previously, if
there is no spare HW thread context, the simulator just fails and stops.
Instead, this patch returns EAGAIN error code from a clone syscall if
there's no available HW thread context. Then it's up to the simulated
program to handle the error.
Linux man page reference:
http://man7.org/linux/man-pages/man2/clone.2.html
http://man7.org/linux/man-pages/man2/fork.2.html
Change-Id: Ib4e092433e49de4dde376c8cb81f7d3f7851cbc0
Reviewed-on: https://gem5-review.googlesource.com/c/9628
Reviewed-by: Brandon Potter <Brandon.Potter@amd.com>
Maintainer: Brandon Potter <Brandon.Potter@amd.com>
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r-- | src/sim/syscall_emul.hh | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index dcd6b5d99..295598c52 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1431,8 +1431,11 @@ cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc) return -EINVAL; ThreadContext *ctc; - if (!(ctc = p->findFreeContext())) - fatal("clone: no spare thread context in system"); + if (!(ctc = p->findFreeContext())) { + DPRINTF_SYSCALL(Verbose, "clone: no spare thread context in system" + "[cpu %d, thread %d]", tc->cpuId(), tc->threadId()); + return -EAGAIN; + } /** * Note that ProcessParams is generated by swig and there are no other |