kvm routine and architecture

2007-12-25 7:44:00

Here is a the original Question and the answers I got .

I removed the name of contributors as I don't know if they are willing to be

published .

Many thanks to those who took time to answer .

Jean Navarro

Digital Equipment

Valbonne

France

Original Question

==================

> I am developping a prog on a SPARC station IPX 4.1.1-IP 4 ,this prog

> is retrieving process information by reading the kernel with kvm routines

> kvm_getproc, kvm_nextproc, kvm_setproc (3K) .

>

> due to the use of these routines ,can someone explain if the resultant BINARY

> exec will run on systems having :

>

> -The same application architecture (sun4)

>

> or

>

> -The same KERNEL architecture only (sun4c)

Answer

=======

Under 4.1.1, it *should*, I think, run on all systems with the same

application architecture. That's not *guaranteed*, though, and it may

not be the case in 4.1.2, say. (Programs that look at the U area

definitely will *not* run on all Sun-4 platforms unchanged; the U area

on non-Sun4m Suns doesn't include the level 1 page table, but the U area

on Sun-4m Suns does.)

Answer

=======

It depends on the parts of the structure that you reference. Sun and

Solbourne appear to put all the architecture-dependent stuff at the end of

the proc structure, so if you only reference the parts that are common to

all the architectures then your binary should work on all SunOS systems.

You can create dependencies, though, if you do anything that references the

size of the proc structure, such as declaring an array of them or using

"sizeof (proc)" in a malloc() call. There are members that are included in

certain architectures using #ifdef, and if you compile on a different

architecture you'll get a different size (what's needed is a

kvm_proc_size() call, to return the size of the proc structure on the

current system).

Answer:

========

>It depends on the parts of the structure that you reference. Sun and

>Solbourne appear to put all the architecture-dependent stuff at the end of

>the proc structure, so if you only reference the parts that are common to

>all the architectures then your binary should work on all SunOS systems.

It gets worse with the user structure, because the pcb structure is

at the beginning, and this varies in size with architecture. It gets

very large for sun4m, for example. You are pretty well forced to compile

separate executables for each architeture even if you use the kvm functions.


--
answer
=======
Hmm. Actually, if you look at the user structure, your program will be
potentially kernel-architecture-dependent; there's a "struct pcb" at the
beginning of the user structure, and on most Suns with in-memory page
tables (Sun-3/80 and Sun-3/4xx, SPARCserver 6xxMP, maybe the 386i), the
level 1 page table is in the PCB, while on Suns with Sun static-RAM
MMUs, it's not.

I.e., you'd need different binaries for Sun-3s and Sun-3x's (the latter
being the 68030 machines), and would also need different binaries for
Sun-4ms (SPARCserver 6xxMP) and other SPARC-based Suns. Other
SPARC-based machines using the SPARC Reference MMU may also have put the
level 1 page table in the PCB....

Answer:
========
-The same KERNEL architecture only (sun4c)
Due to different page size on sun4 and sun4c.

Answer:
=======
There are separate versions of the kvm_* routines for each kernel
architecture. However, if your program is dynamically linked, it
will automatically get the correct version for the machine on which
it is running. As long as the program doesn't use data that is
specific to a particular kernel architecture, it should work correctly
on both sun4's and sun4c's.

Comments

Got something to say?

You must be logged in to post a comment.