Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Jan 1999 10:38:16 -0800
From:      Julian Elischer <julian@whistle.com>
To:        zhihuizhang <bf20761@binghamton.edu>
Cc:        Sabrina Minshall <sabrina@accesscom.com>, hackers <freebsd-hackers@FreeBSD.ORG>
Subject:   Re: stack info
Message-ID:  <36A4D118.1CFBAE39@whistle.com>
References:  <Pine.SOL.L3.93.990119130428.10398B-100000@bingsun2>

next in thread | previous in thread | raw e-mail | index | archive | help
zhihuizhang wrote:
> 
> On Mon, 18 Jan 1999, Sabrina Minshall wrote:
> 
> > Hi Zhihui,
> >
> >    Since you're hot off this topic, I have a question.
> >
> >    1. When a process enters kernel mode (via system call) what
> >         stack is used (in the top half)? is it a common stack to all
> >         processes or is it per process? Where is it located?
> 
> I have not read that part of the source code.  As I understand it, the
> stack you use when you enter into kernel mode is the kernel stack.  It is
> a per-process resource.  It should be at the top of the u-area.  In
> FreeBSD, I think the size of the u-area is two pages.


under -current the kernel stack for each process is a separate KV area.
this is because SMP requires that two processes running at the same time
ahve DIFFERENT addresses for their stacks.
(also needed for threads (processes with shared address spaces))

> 
> >
> > 2. When the kernel is executing in the botton half, what stack is used?
> > is it kstack, or tmpstk?
> 
> kstack is the kernel stack.  tmpstk is used when the CPU is idle (see
> swtch.s).  I am not sure what stack is used when an interrupt happens
> (the kernel is executing in the bottom half).  However, since the
> interrupt handler does not have a process context, it should not use
> kstack.  Maybe there is a third stack reserved for it or it could use
> tmpstk?

At this time the bottom half runs in the kernel stack of whatever
process was running at that time. In -current a separate interrupt 
stack was under consideration but I haven't seen it done yet.

> 
> >
> > 3. Does the kernel have multiple stacks for in the bottom half? Like
> > interrupt stack, etc?
> >
> I am not sure about this.  See above.
> 
> Zhihui Zhang
> ------------
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message

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?36A4D118.1CFBAE39>