Re: linux context switching
From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: 02/09/04
- Next message: Kasper Dupont: "Re: Getting hostname from /proc/dev/tcp"
- Previous message: Siddhartha Jain: "Replicate directories - how to intercept vnode changes"
- In reply to: 惯迭技快扁: "linux context switching"
- Next in thread: Catalin Marinas: "Re: linux context switching"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 09 Feb 2004 11:25:50 +0100
"惯迭技快扁" wrote:
>
> In linux, is there kernel context?
> Assume following sistuation,
> 1. a user process is having CPU
> 2. the process calls systems calls such as ioctl()
> 3. the process is excuted in a kernel mode, at this momnet is there context
> switching?
I guess that depends on your exact definition of a
context switch. The privelege level is changed,
but that is mostly about just changing a few
segment registers. The page tables are not changed
(unless you are using the 4:4 patch). But of course
all registers are saved on the stack.
> 4. H/W interrupt occurs
> 5. save contexts of the process in a kernel mode
> 6. interrupt handler is excuted
> 7. the handler gets finished
Yes that is correct.
> 8. RET is called
No, a special instruction is used to return from
an interrupt. On ia32 the instruction is called
IRET. It does a litle more than just a RET
instruction.
> 9. at this moment, without preemption, the interrupted process in a kernel
> mode will be selected again.
Correct.
> If the steps I mentioned above is right, I think there is no pure kernel
> context to be saved.
All registers must be saved on the stack when the
handler is executed. This means that there will
in fact be two instances of all registers on the
stack. One instance of registers from the user
mode process at the point of entry to the kernel.
And one instance of registers from the process
while executing kernel code at the time of the
interrupt. And whether you call it a context
switch again depends on your definition. We are
switching from a process context to an interrupt
context. But no pages or priveleges are changed.
> All contexts have corresponding user processes. Am I right?
Not exactly. Some processes doesn't have a user
space. Those are the kernel threads like for
example: ksoftirqd, events, kblockd, kapmd,
pdflush, kswapd, aio, pagebufd, kseriod.
> Who owns Task number 0?
Task zero is special. It exists already before
the kernel is booted, and it will eventually
become the idle process, that just sits in a
loop and halts the CPU when nobody else wants
to use it. In an SMP system there will be more
than one task number zero.
> kernel?
Yes.
>
> I have analyzed source codes. But it's very hard to understand them and
> figure out my questions.
>
> Your sincere advices will be appreciated :-)
-- Kasper Dupont -- der bruger for meget tid paa usenet. For sending spam use mailto:aaarep@daimi.au.dk /* Would you like fries with that? */
- Next message: Kasper Dupont: "Re: Getting hostname from /proc/dev/tcp"
- Previous message: Siddhartha Jain: "Replicate directories - how to intercept vnode changes"
- In reply to: 惯迭技快扁: "linux context switching"
- Next in thread: Catalin Marinas: "Re: linux context switching"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|