linux process stack

linux process stack

am 15.05.2010 11:11:09 von ratheesh k

All ,

I am beginner . Please see below my dobts

1. All process and kenel thread has their own task_struct structure
and kernel mode stack . Kernel itself maintain its own stack .


2 .Whenever a process ,say A , switch to kernel ( on system call )
,registers will be stored in its own kernel mode stack ?


3 . On interrupt , process A 's process context will be saved on
process A 's own kernel mode stack ?c


4 .Kernel thread will also use its own kenel mode stack on interrupt ?


5 .Where is the SP ( stack pointer ) is saved ? How it it retrieved back ?


Thanks,
Ratheesh
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: linux process stack

am 17.05.2010 12:08:04 von m.nazarewicz

On Sat, 15 May 2010 11:11:09 +0200, ratheesh k =
wrote:
> 1. All process and kenel thread has their own task_struct structure
> and kernel mode stack . Kernel itself maintain its own stack .

I'm not sure about kernel's own stack but otherwise it's correct.

> 2. Whenever a process, say A, switch to kernel (on system call),
> registers will be stored in its own kernel mode stack ?

Yes.

> 3. On interrupt, process A's process context will be saved on
> process A's own kernel mode stack?

No. On interrupt context is not switched. Interrupt is run in
a context of a task that was running so only registers are saved same
as with system call.

> 4. Kernel thread will also use its own kenel mode stack on interrupt?

As far as I know, kernel threads are in no way special from user tasks
in this regard.

> 5. Where is the SP (stack pointer) is saved? How it it retrieved bac=
k?

It is saved on the kernel mode stack and is retrieved from there.

Note also that this may vary from architecture to architecture and
I'm not an expert.

--=20
Best regards, _ _
| Humble Liege of Serenely Enlightened Majesty of o' \,=3D./ `o
| Computer Science, Michał "mina86" Nazarewicz (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)-- Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie"=
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: linux process stack

am 17.05.2010 18:55:54 von Om Narasimhan

2010/5/17 Michał Nazarewicz :
> On Sat, 15 May 2010 11:11:09 +0200, ratheesh k m>
> wrote:
>>
>> 1. All process and kenel thread has their own task_struct structure
>> and kernel mode stack . Kernel itself maintain its own stack .
>
> I'm not sure about kernel's own stack but otherwise it's correct.
If thread_info size is 8k, then kernel does not have a separate stack.
If it is 4k(1page), then kernel has exception and interrupt stacks,
which are not a part of thread_info.

>
>> 2. Whenever a process, say A, switch to kernel (on system call),
>> registers will be stored in its own kernel mode stack ?
>
> Yes.
>
>> 3. On interrupt, process A's process context will be saved on
>> process A's own kernel mode stack?
>
> No. On interrupt context is not switched. Interrupt is run in
> a context of a task that was running so only registers are saved same
> as with system call.
Unless thread_info is 4k.
>
>> 4. Kernel thread will also use its own kenel mode stack on interrupt=
?
>
> As far as I know, kernel threads are in no way special from user task=
s
> in this regard.
>
>> 5. Where is the SP (stack pointer) is saved? How it it retrieved ba=
ck?
>
> It is saved on the kernel mode stack and is retrieved from there.
Correct. But it can be more complex than that when exceptions occur
and exception handler is to be run in user mode.
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie"=
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs