Questions tagged [context-switch]

A context switch is the process of storing and restoring the state (context) of a process.

In computing, a context switch is the process of storing and restoring the state (context) of a process so that execution can be resumed from the same point at a later time. This enables multiple processes to share a single CPU and is an essential feature of a multitasking operating system. What constitutes the context is determined by the processor and the operating system.

313 questions
7
votes
1 answer

Measure the overhead of context switching in GPU

There are a lot of ways to measure the CPU context switching overhead. It seems it has few resources to measure the GPU context switching overhead. The CPU context switching and GPU's are quite different. The GPU scheduling is based on warp…
LongY
  • 168
  • 1
  • 11
6
votes
2 answers

Figure out when a context switch is happening in Swift

To be honest, I don't know if there might be a solution to my question but I'd like to catch, in Swift, when a context switch is happening. I was imaging a func which takes a long time in order to be completed such as a write operation on a remote…
ndPPPhz
  • 315
  • 1
  • 15
6
votes
2 answers

Why is context-switching an expensive procedure and expensive in terms of what?

In my Operatingsystems class, one of the questions to know for the exam is "Why is context switching expensive?" What do they mean by expensive, and expensive in terms of what? In terms of time it takes to execute the task?
Jean Doe
  • 151
  • 2
  • 10
6
votes
1 answer

Cortex-M4F lazy FPU stacking

I'm writing threading code for a Cortex M4F. Everything's working and I'm now looking into making FPU context switching more efficient via lazy stacking. I've read ARM's AN298 and I implemented the alternative approach based on disabling FPU and…
Andrea Biondo
  • 1,626
  • 14
  • 13
6
votes
1 answer

Windows CPU Scheduler - very high kernel time

We are trying to understand how Windows CPU Scheduler works in order to optimize our applications to achieve maximum possible infrastructure/real work ratio. There's some things in xperf that we don't understand and would like to ask the community…
Igor Malin
  • 652
  • 2
  • 8
  • 26
6
votes
2 answers

What is more expensive? A context switch or a function call?

On a bare metal system (embedded microcontroller, no MMU, no paging) what is more expensive? A full context switch (register save & restore) or a function call (activation record allocation)? I understand that this is highly dependent on calling…
Jon
  • 1,379
  • 1
  • 12
  • 32
6
votes
2 answers

Azure ServiceBus & async - To be, or not to be?

I'm running Service Bus on Azure, pumping about 10-100 messages per second. Recently I've switched to .net 4.5 and all excited refactored all the code to have 'async' and 'await' at least twice in each line to make sure it's done 'properly' :) Now…
user1275154
  • 1,120
  • 1
  • 12
  • 24
5
votes
2 answers

Task Thread Context Switches

I was reading around and read that if I use Tasks instead of Threads in .Net they would not be susceptible to Context Switches that Threads have issues with. However reading around I also noticed that Tasks just use Threads under the covers…
TheWommies
  • 4,922
  • 11
  • 61
  • 79
5
votes
3 answers

Does there have to be a mode switch for something to qualify as a context switch?

Does there have to be a mode switch ie. from user to kernel mode in order for the action to be called a context switch?
rrazd
  • 1,741
  • 2
  • 32
  • 47
5
votes
1 answer

Monitoring context switches in Linux

Is there any way to determine whenever a context switch takes place without the use of profilers? I have written a C program to monitor the time taken for different processes in a program to finish execution. I want to show the process/thread…
Sathya
  • 525
  • 1
  • 8
  • 15
5
votes
1 answer

Can Visual Studio (or any other tool) interpret an address as a beginning of a call stack (boost context)?

Is it possible to tell Visual Studio (or any other tool even on any other major operating system) to interpret an address as a beginning of a call stack? What I'm trying to achieve: we have a library, which uses boost's make_fcontext /…
Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187
5
votes
2 answers

Context Switch Time in Linux Kernel

In Linux Kernel when processor context switches from one thread to another , the state of the registers are saved into PCB and some more bookkeeping is done to ensure that the exact state can be loaded again. This whole saving and loading of the…
5
votes
4 answers

How Java manages the multithread access to elements of arrays?

Hello fellow programmers. I have already asked one question, but despite the really good answers I've got I couldn't fix my problem. Then, I took the time to refactor my code in such a way that would improve its parallelization potential (by having…
5
votes
1 answer

Running two functions concurrently

I want to run two functions one after the other that accesses a third function with a condition that when the first is using the third, the second function should wait. It should be able to use the third function after first time period of accessing…
pranjal khanduri
  • 351
  • 1
  • 3
  • 16
5
votes
1 answer

High CPU usage through context switches in Akka application

I am maintaining and developing two Akka Scala applications that interface with a Serial device to gather sensor information. The main difference between the two is that one (My CO2 sensor application) uses 1% CPU while the other (My Power sensor…
Lolmewn
  • 1,491
  • 4
  • 17
  • 38
1 2
3
20 21