Reputation: 387
Say, a multi-threading app runs on a 8-core Solaris. Is there a way to list the mapping between each thread and core #?
Thanks,
Upvotes: 0
Views: 365
Reputation: 16389
First off, you can write C code to inquire after each thread in a process
Open /proc/[id]/lwp/[tid]/lwpsinfo
there and fetch it into
a lwpsinfo_t
struct defined in procfs.h
processorid_t pr_onpro; /* processor which last ran this lwp */
processorid_t pr_bindpro; /* processor to which lwp is bound */
Are the two members of interest to you. Before you waste your time
Next before you waste a lot of time (assuming zones):
prctl -i zone {ZONENAME}
run by root in the global zone only. You get output like this:
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
zone.max-swap
system 16.0EB max deny -
zone.max-locked-memory
system 16.0EB max deny -
zone.max-shm-memory
system 16.0EB max deny -
zone.max-shm-ids
system 16.8M max deny -
zone.max-sem-ids
system 16.8M max deny -
zone.max-msg-ids
system 16.8M max deny -
zone.max-lwps
system 2.15G max deny -
zone.cpu-cap
privileged 1.20K - deny -
system 4.29G inf deny -
zone.cpu-shares
privileged 1 - none -
system 65.5K max none -
zone.cpu-cap 1.20K means 1200 == means percent. So 1200 means 12 cpus. If I were your admin there is no way a DEV or TEST zone would have 64 cores. So check it first.
Plus, it seems your assumptions are wrong. Unless affinity (processor sets, etc.) is enabled the system assigns cpus to threads using the currently enabled scheduling algorithm (FSS, etc.) This means any thread can go to any available cpu at any time depending on the scheduler and load.
Upvotes: 1