🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
3 messages
3 total messages Started by Xiang Ge Tue, 16 Oct 1990 15:06
the entrance of the process table
#1032
Author: Xiang Ge
Date: Tue, 16 Oct 1990 15:06
7 lines
629 bytes
The process table is a linked list. Can any body tell my how to get
the head of this list, or any other way to get the entrance of the
process table.

Thank you in advance !

xg
Re: the entrance of the process table
#1038
Author: Jack F. Vogel
Date: Tue, 16 Oct 1990 18:14
20 lines
1091 bytes
In article <31229@netnews.upenn.edu> xiang@grad1.cis.upenn.edu (Xiang Ge) writes:
>The process table is a linked list. Can any body tell my how to get
>the head of this list, or any other way to get the entrance of the
>process table.
 

A simple glance at proc.h would give you your answer. Following the proc
structure definition you will find a declaration such as the following:

	extern struct proc proc[];
		-or-
	extern struct proc *proc;

Clear enough?


-- 
Jack F. Vogel			jackv@locus.com
AIX370 Technical Support	       - or -
Locus Computing Corp.		jackv@turnkey.TCC.COM
Re: the entrance of the process table
#1037
Author: Keith Gabryelski
Date: Tue, 16 Oct 1990 20:34
49 lines
1851 bytes
In article <31229@netnews.upenn.edu> xiang@grad1.cis.upenn.edu (Xiang Ge)
writes:
>The process table is a linked list.

Actually it is an array on all unix implementations I am aware of.
Each entry may have links to siblings or children, but it is probably
more use for you to think about it as an array.

>Can any body tell my how to get the head of this list, or any other
>way to get the entrance of the process table.

Depends on your system.  Try:

	If you are on a System V system nlist for `proc' and `v'.
	From `v' get v.nproc (sys/var.h).

	If you are on a BSD system nlist for `proc' and `nproc'.


	Now, if proc_addr is the symbol address you got from nlisting
	for `proc' AND nproc is the symbol adress you got from nlisting
	for `nproc' (or if on System V you nlisted for `v' then read
	that struct in and got `v.nproc'), then:

	if ((fd = open("/dev/kmem", O_RDONLY)) < 0)
	{
		perror("open /dev/kmem");
		exit(1);
	}

#ifdef INDIRECTION_ON_PROC
	lseek(fd, proc_addr, 0);
	read(fd, proc_addr, sizeof(struct proc * ));
#endif

	myproc = (struct proc *)malloc(sizeof(struct proc) * nproc);
	if (!myproc)
	{
		perror("malloc failed");
		exit(1);
	}

	lseek(fd, proc_addr, 0);

	read(fd, myproc, sizeof(struct proc) * nproc);

Pax, Keith

Ps, on some system `proc' will be `_proc', etc.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads