preemption

Can preemptive multitasking of native code be implemented in user space on Linux?

让人想犯罪 __ 提交于 2019-12-04 04:06:30
I'm wondering if it's possible to implement preemptive multitasking of native code within a single process in user space on Linux. (That is, externally pause some running native code, save the context, swap in a different context, and resume execution, all orchestrated by user space but using calls that may enter the kernel.) I was thinking this could be done using a signal handler for SIGALRM , and the *context() family but it turns out that the entire *context() family is async-signal-unsafe so that approach isn't guaranteed to work. I did find a gist that implements this idea so apparently

Why linux disables kernel preemption after the kernel code holds a spinlock?

混江龙づ霸主 提交于 2019-12-03 17:21:28
I am new to Linux and am reading Linux device drivers book by Rubini & Corbet. I am confused at one statement related to spinlocks ; the book states If a nonpreemptive uniprocessor system ever went into a spin on a lock, it would spin forever; no other thread would ever be able to obtain the CPU to release the lock. For this reason, spinlock operations on uniprocessor systems without preemption enabled are optimized to do nothing, with the exception of the ones that change the IRQ masking status. Further the book states The kernel preemption case is handled by the spinlock code itself. Any

Why disabling interrupts disables kernel preemption and how spin lock disables preemption

放肆的年华 提交于 2019-11-30 11:31:11
问题 I am reading Linux Kernel Development recently, and I have a few questions related to disabling preemption. In the "Interrupt Control" section of chapter 7, it says: Moreover, disabling interrupts also disables kernel preemption. I also read from the book that kernel preemption can occur in the follow cases: When an interrupt handler exits, before returning to kernel-space. When kernel code becomes preemptible again. If a task in the kernel explicitly calls schedule() If a task in ther kernel

Linux Kernel Preemption during spin_lock and mutex_lock

两盒软妹~` 提交于 2019-11-30 05:11:14
When a process in the kernel space is holding a spin_lock , the process cannot be preempted due to any of the following conditions : When the time-slice of the process gets exhausted When a high priority process becomes runnable When an interrupt occurs However the process can yield the processor if it blocks, sleeps, or explicitly call schedule() . Is my understanding correct? When a process in the kernel space is holding a mutex_lock , can the process be preempted due to the above conditions listed as 1, 2 and 3. Current implementations of spin locks use two entirely separate mechanisms to

Why disabling interrupts disables kernel preemption and how spin lock disables preemption

删除回忆录丶 提交于 2019-11-29 23:19:00
I am reading Linux Kernel Development recently, and I have a few questions related to disabling preemption. In the "Interrupt Control" section of chapter 7, it says: Moreover, disabling interrupts also disables kernel preemption. I also read from the book that kernel preemption can occur in the follow cases: When an interrupt handler exits, before returning to kernel-space. When kernel code becomes preemptible again. If a task in the kernel explicitly calls schedule() If a task in ther kernel blocks (which results in a call to schedule()) But I can't relate disabling interrupts with these

What is preemption / What is a preemtible kernel? What is it good for?

丶灬走出姿态 提交于 2019-11-29 19:42:19
Explained in your own words, what is preemption and what does it mean to a (linux) kernel? What are advantages and disadvantages in having a preemptible kernel? shoosh Preemptive multitasking - Running several processes/threads on a single processor, creating the illusion that they run concurrently when actually each is allocated small multiplexed time slices to run in. A process is "preempted" when it is scheduled out of execution and waits for the next time slice to run in. A preemptive kernel is one that can be interrupted in the middle of executing code - for instance in response for a

Linux Kernel Preemption during spin_lock and mutex_lock

一曲冷凌霜 提交于 2019-11-29 03:01:14
问题 When a process in the kernel space is holding a spin_lock , the process cannot be preempted due to any of the following conditions : When the time-slice of the process gets exhausted When a high priority process becomes runnable When an interrupt occurs However the process can yield the processor if it blocks, sleeps, or explicitly call schedule() . Is my understanding correct? When a process in the kernel space is holding a mutex_lock , can the process be preempted due to the above

What is an uninterruptable process?

こ雲淡風輕ζ 提交于 2019-11-26 15:34:58
Sometimes whenever I write a program in Linux and it crashes due to a bug of some sort, it will become an uninterruptable process and continue running forever until I restart my computer (even if I log out). My questions are: What causes a process to become uninterruptable? How do I stop that from happening? This is probably a dumb question, but is there any way to interrupt it without restarting my computer? An uninterruptable process is a process which happens to be in a system call (kernel function) that cannot be interrupted by a signal. To understand what that means, you need to