Essentially, the question is whether the interrupt handler can get a valid "current" (address for the current task_structure process), if so, can the content be changed accordingly so that it falls into a "sleep" state, which can be returned by the scheduler later if the state somehow changes. The answer may be hardware dependent.
But in ARM this is impossible, since the "current" is not related to the process in the interrupt mode. See code below:
#linux/arch/arm/include/asm/thread_info.h 94 static inline struct thread_info *current_thread_info(void) 95 { 96 register unsigned long sp asm ("sp"); 97 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); 98 }
sp is in USER mode, and SVC mode is “the same” (“same” here does not mean that they are equal, instead user mode sp points to the user space stack, while svc sp r13_svc mode points to the kernel stack, where user the task_structure process was updated the previous time the task was switched in. When a system call occurs, the process re-enters the kernel space, when sp (sp_svc) still does not change, these 2 sp are connected to each other, in this sense they are 're' same '), therefore in SVC mode, the kernel code can get a valid “current.” But in others, vilegirovannyh modes, for example, interrupt mode, sp is the "other" refers to a dedicated address defined in cpu_init (). " The current "calculated in this mode will not be related to the interrupted process, access to it will lead to unexpected behavior. That's why he always said that the system call can sleep, but the interrupt handler cannot, the system call works in the context of the process, but interrupts him.
samchen2009 Sep 27 '13 at 10:38 on 2013-09-27 10:38
source share