Re: linux context switching

From: Catalin Marinas (c_marinas_at_yahoo.com)
Date: 02/09/04


Date: Mon, 09 Feb 2004 10:36:22 +0000


> In linux, is there kernel context?

Yes.

> 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?

There is no context switching in this case. The kernel address space
(usually starting at 0xc0000000) is mapped in every process address
space. You might get the context switched to a different user process
when returning from the system call.

> 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
> 8. RET is called
> 9. at this moment, without preemption, the interrupted process in a kernel
> mode will be selected again.
> If the steps I mentioned above is right, I think there is no pure kernel
> context to be saved.

There is pure kernel context - the idle task (pid 0) and several kernel
threads.

> I have analyzed source codes. But it's very hard to understand them and
> figure out my questions.

The INIT_TASK definition in include/linux/init_task.h contains active_mm
= &init_mm (which is pure kernel context).

Catalin



Relevant Pages

  • Re: [patch 00/11] ANNOUNCE: "Syslets", generic asynchronous system call support
    ... properly separating the user execution context from the kernel execution ... What about TLS related kernel ...
    (Linux-Kernel)
  • Re: linux context switching
    ... the process is excuted in a kernel mode, at this momnet is there context ... all registers are saved on the stack. ... interrupt handler is excuted ...
    (comp.os.linux.development.system)
  • Re: [PATCH 0 of 4] Generic AIO by scheduling stacks
    ... thought we couldn't do native kernel threads for "normal" threading ... disciplines in question: i hacked on scheduling, 1:1 threading, on Tux, ... the programmer from the risks and complexities of thread programming, ... Having a 1:1 relationship between user-space and kernel-space context is ...
    (Linux-Kernel)
  • Re: 2.4 in-kernel file opening
    ... > There is no way to open files within the kernel. ... It doesn't have a context. ... mmap() is actually what i wanted to do automatically without the need to ... things within the driver before the mmap- I guess that should be ...
    (Linux-Kernel)
  • linux context switching
    ... In linux, is there kernel context? ... a user process is having CPU ... H/W interrupt occurs ...
    (comp.os.linux.development.system)