: Some solaris kernel questions.

: Some solaris kernel questions.

Post by HENG,FO » Sat, 25 Mar 1995 07:23:00



Hi,

I am posting this article on behalf of a friend. Please

=========== Start of article ==========
Hi,

I was using adb to 'look' around in the solaris 2.4 kernel and
developed a few quesion. Hope someone could answer/explain
them for me.

1) I noticed that the adb macro 'setproc' uses 'pidhash'
   to get to the desired proc structure. Does anyone knows what is
   pidhash and how I can make use of it.

   I also noticed that in the 'setproc' macro, the process number
   is 'and'ed with 7f and multiply by 4 before accessing pidhash.
   Anybody knows why you need to do that.

2) Does anyone knows how the proc structure is maintained by
   the kernel. Is there a head pointer which
   points to the begining/first proc structure. How does one proc
   structure links to the other proc structure.

3) I came across the 'proc' adb macro and am not sure with
   how it calculates and prints the 'cid', 'exec, uid' etc.
   Below is the line include from the macro which is suppose
   to do that.

   .>D;<D/n"cid"16t"exec"16t"as"16t"uid"n4+3Xu2+n"lock"
   +$<<mutex                                    ^^

   Does anyone knows why the macro has to add 2 bytes after it
   prints the 'uid' variable. According to /usr/include/sys/proc.h,
   uid is actually typed o_uid_t which is unsigned short and
   2 bytes. Immediately after it is supposed to be p_lock of
   type kmutex_t. Why does it has to add 2 bytes before accessing
   p_lock??

   If I don't add the 2 bytes, all the address for the rest of
   the structure are not correct.

4) I noticed that 'dmesg' will print system messages from previous
   reboots. I thought that system messages are lost after the
   system reboots and dmesg only reports system messages after
   system reboots, not before. Does anyone knows how the kernel
   keeps saves those system messages from previous reboots??

Thanks for any response. Please send replies to


Anyone knows if there is a email-to-usenet facilities for
this newsgroup.

Thanks.

-- Lee, Fook Heng

 
 
 

: Some solaris kernel questions.

Post by Casper H.S. D » Sat, 25 Mar 1995 21:41:28



>1) I noticed that the adb macro 'setproc' uses 'pidhash'
>   to get to the desired proc structure. Does anyone knows what is
>   pidhash and how I can make use of it.

Pid hash is pointer to list of pid structures.

Quote:>   I also noticed that in the 'setproc' macro, the process number
>   is 'and'ed with 7f and multiply by 4 before accessing pidhash.
>   Anybody knows why you need to do that.

Because that's how pidhash works.  You "hash" the process id and
fetch an entry from pidhash.

Quote:>2) Does anyone knows how the proc structure is maintained by
>   the kernel. Is there a head pointer which
>   points to the begining/first proc structure. How does one proc
>   structure links to the other proc structure.

It's a linked list.  New structures are added in the beginning.
The firstpointer is stored in "practive".  You follow then p_next
link of the proc structures.

Quote:>3) I came across the 'proc' adb macro and am not sure with
>   how it calculates and prints the 'cid', 'exec, uid' etc.
>   Below is the line include from the macro which is suppose
>   to do that.
>   .>D;<D/n"cid"16t"exec"16t"as"16t"uid"n4+3Xu2+n"lock"
>   +$<<mutex                                ^^
>   If I don't add the 2 bytes, all the address for the rest of
>   the structure are not correct.

It's just normal structure padding.  (There are two pad bytes after the short)
On the SPARC all structure fields require natural alignment.

Quote:>4) I noticed that 'dmesg' will print system messages from previous
>   reboots. I thought that system messages are lost after the
>   system reboots and dmesg only reports system messages after
>   system reboots, not before. Does anyone knows how the kernel
>   keeps saves those system messages from previous reboots??

In a buffer at the end of the memory.  Powercycle and you see the messages
are lost.

Casper