Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jun 2000 23:16:17 -0400 (EDT)
From:      Luoqi Chen <luoqi@watermarkgroup.com>
To:        freebsd-hackers@FreeBSD.ORG, miklic@ibm.net
Subject:   Re:  Processes, context switching in kernel...
Message-ID:  <200006090316.e593GHC00794@lor.watermarkgroup.com>

next in thread | raw e-mail | index | archive | help
> All,
> 
> 	I'm working on the emulator for OSF1/Mach for FreeBSD/Alpha, and I need
> some help understanding how to do some things in the FreeBSD kernel--if anyone
> can answer any of the following questions, it would be greatly appreciated:
> 
> 1) How do you create a process in the kernel (i.e., you fork in
> user-space...what's the analogue for kernel-space)?
> 
fork1(), see kern_fork.c

> 2) How do you clone a process in kernel-space (i.e., in user-space, you would
> fork and then share the entire process's memory space--how would you do such a
> thing in kernel-space)?
> 
fork1() with RFMEM flag.

> 3) What needs to be done to perform a context switch (from within the kernel),
> and are there any MP considerations when doing this?
> 
Do the following,
	s = splhigh();          
	setrunqueue(p);
	p->p_stats->p_ru.ru_nivcsw++;
	mi_switch();
	splx(s);

nothing special for MP yet, but that's going to change soon...

> 4) In what files do the proc and the u-area structures reside?
> 
If you mean header files, they are <sys/proc.h> and <sys/user.h>.

> Thanks,
> Andrew Miklic
> 

-lq


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006090316.e593GHC00794>