tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: how to tell if a process is 64-bit
On Thu, 14 Sep 2017, Martin Husemann wrote:
> On Thu, Sep 14, 2017 at 02:31:29PM +0200, Thomas Klausner wrote:
> > kp = kvm_getproc2(kvmp, KERN_PROC_PID, pid, sizeof(*kp), &res);
> > if (res != 1)
> > exit(1);
>
> if (kp->p_flag & P_32)
> printf("it is a 32bit process\n");
>
> Unless you are running with a 32bit kernel, then you'll never see that
> flag (but also the question does not make sense).
In theory you could run 64-bit processes on a 32-bit kernel on CPUs that
have disjoint user and kernel address spaces, like sparcv9. In that case
it would make sense to use the P_32 flag to distinguish processes with
32-bit address spaces from those with 64-bit address spaces.
However, it would be a lot of work and probably not worth the effort since
the kernel would be limited to 32-bits of data structures such as file
descriptors and uvm spaces and be hard pressed to keep up with the demands
of 64-bit address spaces. (And implementing copyin/copyout routines would
be fun.)
So yes, at the moment setting the P_32 flag on every process running on a
32-bit kernel seems like a waste of CPU cycles.
Eduardo
Home |
Main Index |
Thread Index |
Old Index