About interrupt handler

2012-02-23 Thread cheneydeng
hi all,
 I'm begin to learn the Kernel and i'm reading Linux kernel 
development.It says This is an important point, always keep in mind that all 
interrupt handler has interrupted other code(possibly even another interrupt 
handler on a different line).What i am not able to understand is how a 
interrupt handler be interrupted ? DID NOT it uninterrupted?


--
best regards!
  cheneydeng___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: About interrupt handler

2012-02-23 Thread Zhengwang Ruan



 Original Message 
From: cheneydeng
Sent: 2012年02月22日 星期三 23时38分37秒
To: kernelnewbies
Subject: About interrupt handler
 hi all,
 I'm begin to learn the Kernel and i'm reading Linux kernel
 development.It says This is an important point, always keep in mind
 that all interrupt handler has interrupted other code(possibly even
 another interrupt handler on a different line).What i am not able to
 understand is how a interrupt handler be interrupted ? DID NOT it
 uninterrupted?

It has more related to CPU architecture. Generally, while an interrupt
handler is being executed, the handler itself can chose to disable or
enable external interrupts (i.e, take x86 for example, IF bit for cflags
reg controls this.). If IF is enabled, then the interrupt handler
currently being executed may be interrupted and then jump to the entry
for the coming interrupt.

Thanks,
-Zhengwang



 --
 best regards!
 cheneydeng


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: About interrupt handler

2012-02-23 Thread cheneydeng
Thanks to all of you~


--
best regards!
  cheneydeng
 

 
 
 
-- Original --
From:  Zhengwang Ruanruan.zhengw...@gmail.com;
Date:  Thu, Feb 23, 2012 06:07 PM
To:  kernelnewbieskernelnewbies@kernelnewbies.org; 

Subject:  Re: About interrupt handler

 
   
   
   
    Original Message 
   From: cheneydeng
   Sent: 2012年02月22日 星期三 23时38分37秒
   To: kernelnewbies
   Subject: About interrupt handler
  hi all,
  I'm begin to learn the Kernel and i'm reading   Linux 
kernel development.It says This is an   important point, always keep 
in mind that all interrupt   handler has interrupted other 
code(possibly even another   interrupt handler on a different 
line).What i am not able to   understand is how a interrupt handler be 
interrupted ? DID NOT   it uninterrupted?
   
  
 It has more related to CPU architecture. Generally, while an interrupt 
handler is being executed, the handler itself can chose to disable or 
enable external interrupts (i.e, take x86 for example, IF bit for cflags 
reg controls this.). If IF is enabled, then the interrupt handler currently 
being executed may be interrupted and then jump to the entry for the coming 
interrupt.
 
 Thanks,
 -Zhengwang
 
 
 
 
  --
best regards!
 cheneydeng
 
   
  
   
___ Kernelnewbies mailing 
list Kernelnewbies@kernelnewbies.org 
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Iterating through all the processes in a module

2012-02-23 Thread Arokux B.
Hi all,

thank you very much guys. Your answers helped me to realize what I
really wanted to do.

Best regards,
Arokux

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: SA_INTERRUPT or SA_SHIRQ

2012-02-23 Thread 卜弋天

Hi Devendra:can you please tell me your kernel version?   SA_INTERRUPT is 
deprecated for many years. it is changed to be IRQF_DISABLED, which is also 
deprecated since 2.6.35.   in kernel 2.6.35, top half interrupt handler will be 
called with interrupts disabled, and for SA_SHIRQ, it is changed to be 
IRQF_SHARED, you should check the return value of request_irq() to see whether 
your irq can be shared with formerregistered irq which use the same int 
line. suppose you are registering irq19 for usb, and the BT module has 
reigstered irq19 with IRQF_SHARED flag, then you are lucky enough to reigter 
correctly for usb. opposite, if BT module registered irq19 without IRQF_SHARED 
flag, then BT will use irq19 alone, it means your register for usb will fail .  
Best Regards
 Date: Wed, 22 Feb 2012 14:56:41 +0530
Subject: SA_INTERRUPT or SA_SHIRQ
From: devendra.rawat.si...@gmail.com
To: kernelnewbies@kernelnewbies.org

Hi All,

If I register an ISR using both the flags SA_INTERRUPT and SA_SHIRQ set, what 
kind of interrupt line will I get a dedicated one or a shared one ?
the exact definition is

request_irq(dev-pci_dev-irq, soc_intr, SA_INTERRUPT | SA_SHIRQ,

  MODULE_NAME, dev);

thanks in advance,
Devendra


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies   
  ___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: pagetables used in interrupt context

2012-02-23 Thread 卜弋天

Hi Subin: for kernel version 2.6.35, ARM architecture, when interrupt 
occurs, kernel will change from USER/SVC mode to IRQ mode,backup some registers 
and change to SVC mode immediately, handle the real interrupt handler in SVC 
mode, which people say in interrupt context.kernel will use the 
stack(interrupt context) of interrupted thread to handle the interrupt, and 
there is no MMU operation which do page table switch.so the thread which is 
interrupted by interrupt, it's kernel mode stack will be choosed as the 
interrupt context of current interrupt.   Date: Tue, 21 Feb 2012 19:18:32 -0700
 Subject: Re: pagetables used in interrupt context
 From: subingangadha...@gmail.com
 To: dhyla...@gmail.com
 CC: kernelnewbies@kernelnewbies.org
 
 Thank you for clearing my doubt.
 
 On Mon, Feb 20, 2012 at 8:39 PM, Dave Hylands dhyla...@gmail.com wrote:
  Hi Subin,
 
  On Mon, Feb 20, 2012 at 6:47 PM, subin gangadharan
  subingangadha...@gmail.com wrote:
  Hi All,
 
  Please correct me if I am wrong. In linux each process will have its
  own page tables, so when a interrupt happens processor will switch to
  interrupt context
  and execute the proper handler. So my doubt, if this is the case,
  interrupt hanlder will be using the pagetables of the interrupted
  process or is there a separate page table for this.
 
  Yep - that's right. Conceptually you can imagine that the kernel page
  tables are replicated in each process, so when the interrupt occurs,
  the kernel mappings will always be in effect regardless of which task
  is running. How this is actually achieved may vary from architecture
  to architecture.
 
  --
  Dave Hylands
  Shuswap, BC, Canada
  http://www.davehylands.com
 
 
 
 -- 
 With Regards
 Subin Gangadharan
 
 I am not afraid and I am also not afraid of being afraid.
 
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
  ___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: SA_INTERRUPT or SA_SHIRQ

2012-02-23 Thread devendra rawat
Hi All,

My comments inline

can you please tell me your kernel version?

It's linux 2.6.10

SA_INTERRUPT is deprecated for many years. it is changed to be
 IRQF_DISABLED, which is also deprecated since 2.6.35.
in kernel 2.6.35, top half interrupt handler will be called with
 interrupts disabled,

and for SA_SHIRQ, it is changed to be IRQF_SHARED, you should check the
 return value of request_irq() to see whether your irq can be shared with
 former
registered irq which use the same int line. suppose you are registering
 irq19 for usb, and the BT module has reigstered irq19 with IRQF_SHARED
 flag, then you are lucky enough to reigter correctly for usb. opposite, if
 BT module registered irq19 without IRQF_SHARED flag, then BT will use irq19
 alone, it means your register for usb will fail .



request_irq(  irq, soc_intr, SA_INTERRUPT | SA_SHIRQ,
  MODULE_NAME, dev);

I am assuming that when I specify both SA_INTERRUPT and SA_SHIRQ in
request_irq then there are 3 possibilities:

1. If the 'irq' is free then I will be granted the line in SA_INTERRUPT
mode i.e all the other maskable interrupts will be disabled when
  my top_half is executing.

2. If the 'irq' is already granted to some other device in SA_SHIRQ mode
then I will also get it in SA_SHIRQ mode i.e all the maskable
interrupts enabled execpt from the device whose ISR Top_half is
executing.

3. If the 'irq' is already granted to some other device in SA_INTERRUPT
mode then my request_irq will fail.


I hope this is the right assumption just my only doubt is does the above
behavior in any way depends on the CPU arch. i.e is it different for x86
and PPC ?


Regards,
Devendra
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: pagetables used in interrupt context

2012-02-23 Thread Subramaniam Appadodharana
On Thu, Feb 23, 2012 at 6:52 AM, 卜弋天 bu...@live.cn wrote:
 Hi Subin:

 for kernel version 2.6.35, ARM architecture, when interrupt occurs,
 kernel will change from USER/SVC mode to IRQ mode,backup some registers and
 change to SVC mode immediately, handle the real interrupt handler in SVC
 mode, which people say in interrupt context.
 kernel will use the stack(interrupt context) of interrupted thread to
 handle the interrupt, and there is no MMU operation which do page table
 switch.
 so the thread which is interrupted by interrupt, it's kernel mode stack
 will be choosed as the interrupt context of current interrupt.

Thanks ! thats a terse explanation! Can you please mention why we do
not have a IRQ stack (in terms of size of the stack) to do the
processing?

 Date: Tue, 21 Feb 2012 19:18:32 -0700
 Subject: Re: pagetables used in interrupt context
 From: subingangadha...@gmail.com
 To: dhyla...@gmail.com
 CC: kernelnewbies@kernelnewbies.org


 Thank you for clearing my doubt.

 On Mon, Feb 20, 2012 at 8:39 PM, Dave Hylands dhyla...@gmail.com wrote:
  Hi Subin,
 
  On Mon, Feb 20, 2012 at 6:47 PM, subin gangadharan
  subingangadha...@gmail.com wrote:
  Hi All,
 
  Please correct me if I am wrong. In linux each process will have its
  own page tables, so when a interrupt happens processor will switch to
  interrupt context
  and execute the proper handler. So my doubt, if this is the case,
  interrupt hanlder will be using the pagetables of the interrupted
  process or is there a separate page table for this.
 
  Yep - that's right. Conceptually you can imagine that the kernel page
  tables are replicated in each process, so when the interrupt occurs,
  the kernel mappings will always be in effect regardless of which task
  is running. How this is actually achieved may vary from architecture
  to architecture.
 
  --
  Dave Hylands
  Shuswap, BC, Canada
  http://www.davehylands.com



 --
 With Regards
 Subin Gangadharan

 I am not afraid and I am also not afraid of being afraid.

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: pagetables used in interrupt context

2012-02-23 Thread 卜弋天

Hi : for ARM architecture, from the point of my view, interrupt can be 
handled in IRQ, SVC, or SYSTEM modes.1.if kernel handles interrupt in IRQ 
mode, it can use separate specific stack of IRQ mode to handle interrupt,but it 
cannot support nest interupt, suppose you are running interrupt handler in IRQ 
mode, a new coming interrupt will corrupt the lr_irq which is used for current 
function.2. if kernel handles interrupt in SYSTEM mode, the sequences will 
be : hardware interrupt occurs--IRQ mode--SYSTEM mode --call interrupt 
handler.   kernel can support nest interrupt well by this way, the problem 
is SYSTEM mode use the same register with USER mode, which means kernel will 
use the  interrupted thread's user mode stack, this will leake information of 
kernel to user space, so it is not a good idea, although i did this for many 
years for OMAP chipset(the OS is not linux, it is mixed by REX and my own 
design.).3. Linux kernel choose the last one, handle interrupt in SVC mode, 
which can support nest interrupt if it wants(2.6.35 does not support this). and 
it is very simple to use the interrupted thread's kernel mode stack as the 
interrupt context. if kernel use a specific stack which is for interrupt only, 
the sequences will be : hardware interrupt occurs--IRQ mode--SVC 
mode--backup sp register of interrupted thread to it's TCB---set sp register 
to be the specific kernel stack address--call interrupt handler---restore sp 
of interrupted thread---return from interrupt.this is a little 
complicated compared with the current design. so i agree with the current 
design.  Best Regards
  Date: Thu, 23 Feb 2012 08:41:28 -0600
 Subject: Re: pagetables used in interrupt context
 From: c.a.subraman...@gmail.com
 To: bu...@live.cn
 CC: dhyla...@gmail.com; subingangadha...@gmail.com; 
 kernelnewbies@kernelnewbies.org
 
 On Thu, Feb 23, 2012 at 6:52 AM, 卜弋天 bu...@live.cn wrote:
  Hi Subin:
 
  for kernel version 2.6.35, ARM architecture, when interrupt occurs,
  kernel will change from USER/SVC mode to IRQ mode,backup some registers and
  change to SVC mode immediately, handle the real interrupt handler in SVC
  mode, which people say in interrupt context.
  kernel will use the stack(interrupt context) of interrupted thread to
  handle the interrupt, and there is no MMU operation which do page table
  switch.
  so the thread which is interrupted by interrupt, it's kernel mode stack
  will be choosed as the interrupt context of current interrupt.
 
 Thanks ! thats a terse explanation! Can you please mention why we do
 not have a IRQ stack (in terms of size of the stack) to do the
 processing?
 
  Date: Tue, 21 Feb 2012 19:18:32 -0700
  Subject: Re: pagetables used in interrupt context
  From: subingangadha...@gmail.com
  To: dhyla...@gmail.com
  CC: kernelnewbies@kernelnewbies.org
 
 
  Thank you for clearing my doubt.
 
  On Mon, Feb 20, 2012 at 8:39 PM, Dave Hylands dhyla...@gmail.com wrote:
   Hi Subin,
  
   On Mon, Feb 20, 2012 at 6:47 PM, subin gangadharan
   subingangadha...@gmail.com wrote:
   Hi All,
  
   Please correct me if I am wrong. In linux each process will have its
   own page tables, so when a interrupt happens processor will switch to
   interrupt context
   and execute the proper handler. So my doubt, if this is the case,
   interrupt hanlder will be using the pagetables of the interrupted
   process or is there a separate page table for this.
  
   Yep - that's right. Conceptually you can imagine that the kernel page
   tables are replicated in each process, so when the interrupt occurs,
   the kernel mappings will always be in effect regardless of which task
   is running. How this is actually achieved may vary from architecture
   to architecture.
  
   --
   Dave Hylands
   Shuswap, BC, Canada
   http://www.davehylands.com
 
 
 
  --
  With Regards
  Subin Gangadharan
 
  I am not afraid and I am also not afraid of being afraid.
 
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
 
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
  ___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: pagetables used in interrupt context

2012-02-23 Thread subin gangadharan
Hi ,

 can support nest interrupt if it wants(2.6.35 does not support this). and it
 is very simple to use the interrupted thread's kernel mode stack as the
 interrupt context. if kernel use a specific stack which is for interrupt

Thanks for the crystal clear explanation of the page table usage in
interrupt context. I have one more doubt, so in 2.6.35 as you said it
doesn't support
nested interrupt, does it mean that all other interrupts are
completely disabled, (I mean no other can interrupt the processor)
while executing an interrupt handler.



2012/2/23 卜弋天 bu...@live.cn:
 Hi :

 for ARM architecture, from the point of my view, interrupt can be
 handled in IRQ, SVC, or SYSTEM modes.
 1.if kernel handles interrupt in IRQ mode, it can use separate specific
 stack of IRQ mode to handle interrupt,but it cannot support nest interupt,
 suppose you are running interrupt handler in IRQ mode, a new coming
 interrupt will corrupt the lr_irq which is used for current function.
 2. if kernel handles interrupt in SYSTEM mode, the sequences will be :
 hardware interrupt occurs--IRQ mode--SYSTEM mode --call
 interrupt handler.
kernel can support nest interrupt well by this way, the problem is
 SYSTEM mode use the same register with USER mode, which means kernel will
 use the  interrupted thread's user mode stack, this will leake information
 of kernel to user space, so it is not a good idea, although i did this for
 many years for OMAP chipset(the OS is not linux, it is mixed by REX and my
 own design.).
 3. Linux kernel choose the last one, handle interrupt in SVC mode, which
 can support nest interrupt if it wants(2.6.35 does not support this). and it
 is very simple to use the interrupted thread's kernel mode stack as the
 interrupt context. if kernel use a specific stack which is for interrupt
 only, the sequences will be : hardware interrupt occurs--IRQ mode--SVC
 mode--backup sp register of interrupted thread to it's TCB---set sp
 register to be the specific kernel stack address--call interrupt
 handler---restore sp of interrupted thread---return from interrupt.
 this is a little complicated compared with the current design. so i
 agree with the current design.


 Best Regards

 Date: Thu, 23 Feb 2012 08:41:28 -0600

 Subject: Re: pagetables used in interrupt context
 From: c.a.subraman...@gmail.com
 To: bu...@live.cn
 CC: dhyla...@gmail.com; subingangadha...@gmail.com;
 kernelnewbies@kernelnewbies.org


 On Thu, Feb 23, 2012 at 6:52 AM, 卜弋天 bu...@live.cn wrote:
  Hi Subin:
 
  for kernel version 2.6.35, ARM architecture, when interrupt occurs,
  kernel will change from USER/SVC mode to IRQ mode,backup some registers
  and
  change to SVC mode immediately, handle the real interrupt handler in SVC
  mode, which people say in interrupt context.
  kernel will use the stack(interrupt context) of interrupted thread to
  handle the interrupt, and there is no MMU operation which do page table
  switch.
  so the thread which is interrupted by interrupt, it's kernel mode stack
  will be choosed as the interrupt context of current interrupt.
 
 Thanks ! thats a terse explanation! Can you please mention why we do
 not have a IRQ stack (in terms of size of the stack) to do the
 processing?
 
  Date: Tue, 21 Feb 2012 19:18:32 -0700
  Subject: Re: pagetables used in interrupt context
  From: subingangadha...@gmail.com
  To: dhyla...@gmail.com
  CC: kernelnewbies@kernelnewbies.org
 
 
  Thank you for clearing my doubt.
 
  On Mon, Feb 20, 2012 at 8:39 PM, Dave Hylands dhyla...@gmail.com
  wrote:
   Hi Subin,
  
   On Mon, Feb 20, 2012 at 6:47 PM, subin gangadharan
   subingangadha...@gmail.com wrote:
   Hi All,
  
   Please correct me if I am wrong. In linux each process will have its
   own page tables, so when a interrupt happens processor will switch
   to
   interrupt context
   and execute the proper handler. So my doubt, if this is the case,
   interrupt hanlder will be using the pagetables of the interrupted
   process or is there a separate page table for this.
  
   Yep - that's right. Conceptually you can imagine that the kernel page
   tables are replicated in each process, so when the interrupt occurs,
   the kernel mappings will always be in effect regardless of which task
   is running. How this is actually achieved may vary from architecture
   to architecture.
  
   --
   Dave Hylands
   Shuswap, BC, Canada
   http://www.davehylands.com
 
 
 
  --
  With Regards
  Subin Gangadharan
 
  I am not afraid and I am also not afraid of being afraid.
 
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 

 ___
 Kernelnewbies mailing list
 

How to debug system freeze?

2012-02-23 Thread Łukasz Sowa
Hi,

I'm experiencing strange bug when I close lid of my laptop - system
freezes (no reaction on keys, no response form ssh) hard and displays
some strange colour effects. The kernel log (after reboot) shows
nothing. My question is - how to debug it? Maybe there's a way to track
last called kernel function or something similar?

Thanks,
Lukasz Sowa

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: The 2.6.32 Linux kernel patches

2012-02-23 Thread Julie Sullivan
 Also I'm new to git, does  any one have a good tutorial on this with
 focus on Linux kernel development?

Here's a couple of guides with hints I've found useful:

http://linux.yyz.us/git-howto.html

http://progit.org/


HTH,

Cheers
Julie

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: pagetables used in interrupt context

2012-02-23 Thread 卜弋天

Hi Subin:
 
 i am not familiar with other architecture, but for ARM, Linux Kernel 
2.6.35, i checked the function handle_level_irq()and handle_edge_irq() in 
chip.c, both of them will call handle_IRQ_event() which is in handle.c. and the 
function handle_IRQ_event() will call the interrupt handler written by user. 
Kernel does not open interrupt(ARM CPSR I bit)when calling interrupt handler in 
handle_IRQ_event() function. this is only for top-half interrupt handling.  for 
bottom-half, it is no doubt that the interrupt will be opened.
 
 so if you register a interrupt by request_irq(), the interrupt handler 
will be called with irq disabled. i tested on Cortex-A9 dual core platform, it 
is right.
 

 

 Date: Thu, 23 Feb 2012 11:12:06 -0600
 Subject: Re: pagetables used in interrupt context
 From: subingangadha...@gmail.com
 To: bu...@live.cn
 CC: c.a.subraman...@gmail.com; dhyla...@gmail.com; 
 kernelnewbies@kernelnewbies.org
 
 Hi ,
 
  can support nest interrupt if it wants(2.6.35 does not support this). and it
  is very simple to use the interrupted thread's kernel mode stack as the
  interrupt context. if kernel use a specific stack which is for interrupt
 
 Thanks for the crystal clear explanation of the page table usage in
 interrupt context. I have one more doubt, so in 2.6.35 as you said it
 doesn't support
 nested interrupt, does it mean that all other interrupts are
 completely disabled, (I mean no other can interrupt the processor)
 while executing an interrupt handler.
 
 
 
 2012/2/23 卜弋天 bu...@live.cn:
  Hi :
 
  for ARM architecture, from the point of my view, interrupt can be
  handled in IRQ, SVC, or SYSTEM modes.
  1.if kernel handles interrupt in IRQ mode, it can use separate specific
  stack of IRQ mode to handle interrupt,but it cannot support nest interupt,
  suppose you are running interrupt handler in IRQ mode, a new coming
  interrupt will corrupt the lr_irq which is used for current function.
  2. if kernel handles interrupt in SYSTEM mode, the sequences will be :
  hardware interrupt occurs--IRQ mode--SYSTEM mode --call
  interrupt handler.
  kernel can support nest interrupt well by this way, the problem is
  SYSTEM mode use the same register with USER mode, which means kernel will
  use the interrupted thread's user mode stack, this will leake information
  of kernel to user space, so it is not a good idea, although i did this for
  many years for OMAP chipset(the OS is not linux, it is mixed by REX and my
  own design.).
  3. Linux kernel choose the last one, handle interrupt in SVC mode, which
  can support nest interrupt if it wants(2.6.35 does not support this). and it
  is very simple to use the interrupted thread's kernel mode stack as the
  interrupt context. if kernel use a specific stack which is for interrupt
  only, the sequences will be : hardware interrupt occurs--IRQ mode--SVC
  mode--backup sp register of interrupted thread to it's TCB---set sp
  register to be the specific kernel stack address--call interrupt
  handler---restore sp of interrupted thread---return from interrupt.
  this is a little complicated compared with the current design. so i
  agree with the current design.
 
 
  Best Regards
 
  Date: Thu, 23 Feb 2012 08:41:28 -0600
 
  Subject: Re: pagetables used in interrupt context
  From: c.a.subraman...@gmail.com
  To: bu...@live.cn
  CC: dhyla...@gmail.com; subingangadha...@gmail.com;
  kernelnewbies@kernelnewbies.org
 
 
  On Thu, Feb 23, 2012 at 6:52 AM, 卜弋天 bu...@live.cn wrote:
   Hi Subin:
  
   for kernel version 2.6.35, ARM architecture, when interrupt occurs,
   kernel will change from USER/SVC mode to IRQ mode,backup some registers
   and
   change to SVC mode immediately, handle the real interrupt handler in SVC
   mode, which people say in interrupt context.
   kernel will use the stack(interrupt context) of interrupted thread to
   handle the interrupt, and there is no MMU operation which do page table
   switch.
   so the thread which is interrupted by interrupt, it's kernel mode stack
   will be choosed as the interrupt context of current interrupt.
  
  Thanks ! thats a terse explanation! Can you please mention why we do
  not have a IRQ stack (in terms of size of the stack) to do the
  processing?
  
   Date: Tue, 21 Feb 2012 19:18:32 -0700
   Subject: Re: pagetables used in interrupt context
   From: subingangadha...@gmail.com
   To: dhyla...@gmail.com
   CC: kernelnewbies@kernelnewbies.org
  
  
   Thank you for clearing my doubt.
  
   On Mon, Feb 20, 2012 at 8:39 PM, Dave Hylands dhyla...@gmail.com
   wrote:
Hi Subin,
   
On Mon, Feb 20, 2012 at 6:47 PM, subin gangadharan
subingangadha...@gmail.com wrote:
Hi All,
   
Please correct me if I am wrong. In linux each process will have its
own page tables, so when a interrupt happens processor will switch
to
interrupt context
and execute the proper handler. So my doubt, if this is the case,
interrupt hanlder will be using the 

Re: Semaphore

2012-02-23 Thread Kosta Zertsekel
  Imagine a driver which only one app can use at a time (perhaps a serial
  port). The kernel will take a lock when the user space app open()s the
  device node and release it when it close()s.
  If the app segfaults in between the open() and close() the lock will
  still get released. The kernel always cleans up open files for stopped
  processes, regardless of how they stop. During this cleanup the kernel
  will close() the device node, and as a result the driver will release
  the lock.

Can you please point to some code in Linux Kernel that does the job?
Thanks,
--- KostaZ

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies