context-switch

What is saved in a context switch?

試著忘記壹切 提交于 2019-12-18 13:07:02
问题 What is exactly saved and restored in a context switch between two threads in the same process between two processes 回答1: This is rather a complex question since the answer(s) are dependent on many things: The CPU in question It can vary significantly even within the same family for example the additional registers added for SSE/MMX operations. The operating system, since it controls the handlers which trigger on a context switch and decide whether the CPU's hardware (if any) to assist in a

Cost of context switch between threads of same process, on Linux

三世轮回 提交于 2019-12-18 11:46:23
问题 Is there any good empirical data on the cost of context switching between threads of the same process on Linux (x86 and x86_64, mainly, are of interest)? I'm talking about the number of cycles or nanoseconds between the last instruction one thread executes in userspace before getting put to sleep voluntarily or involuntarily, and the first instruction a different thread of the same process executes after waking up on the same cpu/core. I wrote a quick test program that constantly performs

MultiCore CPUs, Multithreading and context switching?

▼魔方 西西 提交于 2019-12-17 19:20:00
问题 Let's say we have a CPU with 20 cores and a process with 20 CPU-intensive independent of each other threads: One thread per CPU core. I'm trying to figure out whether context switching happens in this case. I believe it happens because there are system processes in the operating system that need CPU-time too. I understand that there are different CPU architectures and some answers may vary but can you please explain: How context switching happens e.g. on Linux or Windows and some known CPU

DIFFERENT TASKS ASSIGNED TO DIFFERENT INSTANCES OF FORK() OF A PROCESS IN C

≡放荡痞女 提交于 2019-12-14 04:23:58
问题 Can I assign different task to different instances of fork() of a process in C ? like for example: program.c has been forked 3 times int main() { pid_t pid; pid = fork(); pid = fork(); pid = fork(); } now to every instance of fork() I want to do different thing, Can I do this? with forks ? or any other method if favorable? :) PS: I am testing Real Time Linux and want to check the performance of the Context Switching through forks through Time Constraint. 回答1: You can use posix process.. posix

What is cost of context switching to secure mode (arm trustzone)

纵然是瞬间 提交于 2019-12-13 13:18:57
问题 I am trying to understand the cost of switching back and forth between trusted (secure) and non-secure modes in arm. What exactly needs to happen when moving from non-secure to secure world? I know the ns bit needs to be set (based on some special instruction?), the page tables need to be flushed and updated (?), the processor caches flushed and updated. Anything else that needs to happen? Processor caches: Are they caches segmented and shared or is the whole cache used for each mode? That

Where to return from an interrupt

北城余情 提交于 2019-12-12 19:21:50
问题 I've read (and studied) about Interrupt Handling. What I always fail to understand, is how do we know where to return to (PC / IP) from the Interrupt Handler. As I understand it: An Interrupt is caused by a device (say the keyboard) The relevant handler is called - under the running process. That is, no context switch to the OS is performed. The Interrupt Handler finishes, and passes control back to the running application. The process depicted above, which is my understanding of Interrupt

Seg fault when returning to function execution after successful swapcontext

余生长醉 提交于 2019-12-11 18:01:25
问题 I'm trying to write a library to manage threads using contexts(getcontext, setcontext, makecontext, swapcontext), without pthreads. A function MyThreadYield(), pauses the current thread context, sends it to the end of ready queue and starts executing the thread at the head of ready queue. In MyThreadYield(), I am able to retrieve context of paused thread via swapcontext() but just when it is returning to the function execution I get a segfault. Eg :- Suppose thread 1 is the init thread, it

Linux context switch internals: how does a process goes back to userland after the switch?

こ雲淡風輕ζ 提交于 2019-12-11 15:37:36
问题 I have read a similar answer to question regarding context switching on StackOverflow: How does schedule()+switch_to() functions from linux kernel actually work? However, i'm still puzzled by the internals and lack the understanding of how a newly switched process (previously preempted) will resume its execution in userland (assuming it was interrupted there) on Linux. So far, the general flow of the context switch (on v4.20 ): a process is executing in userland (lets say firefox ) the CPU

Process.Start() not spawning new process under the same user

你。 提交于 2019-12-11 07:25:18
问题 I was always under the impression that when you're running a process as (domain\user) mydomain\myuser , when using Process.Start() it would start this new process using the same credentials - mydomain\myuser . The issue I'm having is that my Process.Start() call seems to be creating a process under the SYSTEM account which is causing me permission issues in the started process (which must run under an admin account due to the work it does). If it changes things - I'm spawning this process (a

Can my thread help the OS decide when to context switch it out?

自闭症网瘾萝莉.ら 提交于 2019-12-09 09:25:40
问题 I am working on a threaded application on Linux in C++ which attempts to be real time, doing an action on a heartbeat, or as close to it as possible. In practice, I find the OS is swapping out my thread and causing delays of up to a tenth of a second while it is switched out, causing the heartbeat to be irregular. Is there a way my thread can hint to the OS that now is a good time to context switch it out? I could make this call right after doing a heartbeat, and thus minimize the delay due