24.22.6.4. gem5 Process
The Process
class is used only for gem5 syscall emulation mode, and it represents a process like a Linux userland process, in addition to any further gem5 specific data needed to represent the process.
The first thing most syscall implementations do is to actually pull Process
out of gem5 ThreadContext
, e.g.:
template <class OS> SyscallReturn readFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr buf_ptr, int nbytes) { auto p = tc->getProcessPtr();
For example, we can readily see from its interface that it contains several accessors for common process fields:
inline uint64_t uid() { return _uid; } inline uint64_t euid() { return _euid; } inline uint64_t gid() { return _gid; } inline uint64_t egid() { return _egid; }
Process
is a SimObject
, and therefore produced directly in e.g. se.py.
se.py produces one process per-executable given:
workloads = options.cmd.split(';') idx = 0 for wrkld in workloads: process = Process(pid = 100 + idx)
and those are placed in the workload
property:
for i in range(np): if options.smt: system.cpu[i].workload = multiprocesses elif len(multiprocesses) == 1: system.cpu[i].workload = multiprocesses[0] else: system.cpu[i].workload = multiprocesses[i]
and finally each thread of a CPU gets assigned to a different such workload:
BaseSimpleCPU::BaseSimpleCPU(BaseSimpleCPUParams *p) : BaseCPU(p), curThread(0), branchPred(p->branchPred), traceData(NULL), inst(), _status(Idle) { SimpleThread *thread; for (unsigned i = 0; i < numThreads; i++) { if (FullSystem) { thread = new SimpleThread(this, i, p->system, p->itb, p->dtb, p->isa[i]); } else { thread = new SimpleThread(this, i, p->system, p->workload[i], p->itb, p->dtb, p->isa[i]); } threadInfo.push_back(new SimpleExecContext(this, thread)); ThreadContext *tc = thread->getTC(); threadContexts.push_back(tc); }