diff --git a/src/sim/process.hh b/src/sim/process.hh --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -79,9 +79,6 @@ // thread contexts associated with this process std::vector contextIds; - // number of CPUs (esxec contexts, really) assigned to this process. - unsigned int numCpus() { return contextIds.size(); } - // record of blocked context struct WaitRec { diff --git a/src/kern/tru64/tru64.hh b/src/kern/tru64/tru64.hh --- a/src/kern/tru64/tru64.hh +++ b/src/kern/tru64/tru64.hh @@ -608,21 +608,23 @@ cur_addr += sizeof(Tru64::nxm_config_info); // next comes the per-cpu state vector Addr slot_state_addr = cur_addr; - int slot_state_size = - process->numCpus() * sizeof(Tru64::nxm_slot_state_t); + + uint32_t num_threads = process->contextIds.size(); + + int slot_state_size = num_threads * sizeof(Tru64::nxm_slot_state_t); cur_addr += slot_state_size; // now the per-RAD state struct (we only support one RAD) cur_addr = 0x14000; // bump up addr for alignment Addr rad_state_addr = cur_addr; int rad_state_size = (sizeof(Tru64::nxm_shared) - + (process->numCpus()-1) * sizeof(Tru64::nxm_sched_state)); + + (num_threads - 1) * sizeof(Tru64::nxm_sched_state)); cur_addr += rad_state_size; // now initialize a config_info struct and copy it out to user space TypedBufferArg config(config_addr); - config->nxm_nslots_per_rad = htog(process->numCpus()); + config->nxm_nslots_per_rad = htog(num_threads); config->nxm_nrads = htog(1); // only one RAD in our system! config->nxm_slot_state = htog(slot_state_addr); config->nxm_rad[0] = htog(rad_state_addr); @@ -630,7 +632,7 @@ // initialize the slot_state array and copy it out TypedBufferArg slot_state(slot_state_addr, slot_state_size); - for (int i = 0; i < process->numCpus(); ++i) { + for (int i = 0; i < num_threads; ++i) { // CPU 0 is bound to the calling process; all others are available // XXX this code should have an endian conversion, but I don't think // it works anyway @@ -647,7 +649,7 @@ rad_state->nxm_callback = attrp->nxm_callback; rad_state->nxm_version = attrp->nxm_version; rad_state->nxm_uniq_offset = attrp->nxm_uniq_offset; - for (int i = 0; i < process->numCpus(); ++i) { + for (int i = 0; i < num_threads; ++i) { Tru64::nxm_sched_state *ssp = &rad_state->nxm_ss[i]; ssp->nxm_u.sigmask = htog(0); ssp->nxm_u.sig = htog(0); @@ -731,7 +733,9 @@ abort(); } - if (thread_index < 0 || thread_index > process->numCpus()) { + uint32_t num_threads = process->contextIds.size(); + + if (thread_index < 0 || thread_index > num_threads) { cerr << "nxm_thread_create: bad thread index " << thread_index << endl; abort(); @@ -743,7 +747,7 @@ // back out again. int rad_state_size = (sizeof(Tru64::nxm_shared) + - (process->numCpus()-1) * sizeof(Tru64::nxm_sched_state)); + (num_threads - 1) * sizeof(Tru64::nxm_sched_state)); TypedBufferArg rad_state(0x14000, rad_state_size); @@ -775,8 +779,8 @@ rad_state.copyOut(tc->getMemProxy()); Addr slot_state_addr = 0x12000 + sizeof(Tru64::nxm_config_info); - int slot_state_size = - process->numCpus() * sizeof(Tru64::nxm_slot_state_t); + int slot_state_size = num_threads + * sizeof(Tru64::nxm_slot_state_t); TypedBufferArg slot_state(slot_state_addr, # Node ID b71b3bd60a7007779494cce3853fc98df953cd39 # Parent ebff480ad584c7a87eb6bbdfa72c2e7e6b57e1f0 diff --git a/src/arch/alpha/tru64/process.cc b/src/arch/alpha/tru64/process.cc --- a/src/arch/alpha/tru64/process.cc +++ b/src/arch/alpha/tru64/process.cc @@ -70,18 +70,20 @@ Addr bufPtr = process->getSyscallArg(tc, index); unsigned nbytes = process->getSyscallArg(tc, index); + uint32_t num_threads = process->contextIds.size(); + switch (op) { case AlphaTru64::GSI_MAX_CPU: { TypedBufferArg max_cpu(bufPtr); - *max_cpu = htog((uint32_t)process->numCpus()); + *max_cpu = htog(num_threads); max_cpu.copyOut(tc->getMemProxy()); return 1; } case AlphaTru64::GSI_CPUS_IN_BOX: { TypedBufferArg cpus_in_box(bufPtr); - *cpus_in_box = htog((uint32_t)process->numCpus()); + *cpus_in_box = htog(num_threads); cpus_in_box.copyOut(tc->getMemProxy()); return 1; } @@ -97,10 +99,10 @@ TypedBufferArg infop(bufPtr); infop->current_cpu = htog(0); - infop->cpus_in_box = htog(process->numCpus()); + infop->cpus_in_box = htog(num_threads); infop->cpu_type = htog(57); - infop->ncpus = htog(process->numCpus()); - uint64_t cpumask = (1 << process->numCpus()) - 1; + infop->ncpus = htog(num_threads); + uint64_t cpumask = (1 << num_threads) - 1; infop->cpus_present = infop->cpus_running = htog(cpumask); infop->cpu_binding = htog(0); infop->cpu_ex_binding = htog(0); @@ -177,6 +179,8 @@ int nel = process->getSyscallArg(tc, argIndex); // number of elements int lel = process->getSyscallArg(tc, argIndex); // expected element size + uint32_t num_threads = process->contextIds.size(); + switch (id) { case AlphaTru64::TBL_SYSINFO: { if (index != 0 || nel != 1 || lel != sizeof(Tru64::tbl_sysinfo)) @@ -192,7 +196,7 @@ elp->si_hz = htog(clk_hz); elp->si_phz = htog(clk_hz); elp->si_boottime = htog(seconds_since_epoch); // seconds since epoch? - elp->si_max_procs = htog(process->numCpus()); + elp->si_max_procs = htog(num_threads); elp.copyOut(tc->getMemProxy()); return 0; }