diff options
author | Brandon Potter <brandon.potter@amd.com> | 2017-02-27 14:10:02 -0500 |
---|---|---|
committer | Brandon Potter <brandon.potter@amd.com> | 2017-02-27 14:10:02 -0500 |
commit | 073cb266079edddec64ea8cd5169dd2cbef8f812 (patch) | |
tree | 63de367b090c3aae3e4c3ea5b43949c899c8e811 /src/sim/syscall_emul.cc | |
parent | f5656738dc3ded25ba8a269efff70e8f12fc22ee (diff) | |
download | gem5-073cb266079edddec64ea8cd5169dd2cbef8f812.tar.xz |
syscall_emul: [patch 14/22] adds identifier system calls
This changeset add fields to the process object and adds the following
three system calls: setpgid, gettid, getpid.
Diffstat (limited to 'src/sim/syscall_emul.cc')
-rw-r--r-- | src/sim/syscall_emul.cc | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 281e4c021..c6b89b0c7 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -729,6 +729,41 @@ pipePseudoFunc(SyscallDesc *desc, int callnum, Process *process, return sim_fds[0]; } +SyscallReturn +setpgidFunc(SyscallDesc *desc, int callnum, Process *process, + ThreadContext *tc) +{ + int index = 0; + int pid = process->getSyscallArg(tc, index); + int pgid = process->getSyscallArg(tc, index); + + if (pgid < 0) + return -EINVAL; + + if (pid == 0) { + process->setpgid(process->pid()); + return 0; + } + + Process *matched_ph = NULL; + System *sysh = tc->getSystemPtr(); + + // Retrieves process pointer from active/suspended thread contexts. + for (int i = 0; i < sysh->numContexts(); i++) { + if (sysh->threadContexts[i]->status() != ThreadContext::Halted) { + Process *temp_h = sysh->threadContexts[i]->getProcessPtr(); + Process *walk_ph = (Process*)temp_h; + + if (walk_ph && walk_ph->pid() == process->pid()) + matched_ph = walk_ph; + } + } + + assert(matched_ph != NULL); + matched_ph->setpgid((pgid == 0) ? matched_ph->pid() : pgid); + + return 0; +} SyscallReturn getpidPseudoFunc(SyscallDesc *desc, int callnum, Process *process, @@ -780,11 +815,13 @@ SyscallReturn getpidFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc) { - // Make up a PID. There's no interprocess communication in - // fake_syscall mode, so there's no way for a process to know it's - // not getting a unique value. + return process->tgid(); +} - tc->setIntReg(SyscallPseudoReturnReg, process->ppid()); //PID +SyscallReturn +gettidFunc(SyscallDesc *desc, int callnum, Process *process, + ThreadContext *tc) +{ return process->pid(); } |