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
5
votes
1 answer

Is it possible to reduce the context switch time

MediaRecorder.start() takes much time. Method Profiling says that 'context switch' - Inclusive Real Time is 100% and takes about 1510 ms. Is it possible to reduce it somehow? I need it to be as fast as possible.
Yuliya Tarasenko
  • 437
  • 2
  • 19
5
votes
3 answers

How each thread can have CPU registers

At several places I have read, Each thread has its own set of CPU registers and its own stack Here, I can understand about stack, it's a data structure. But how thread can have its own CPU registers. They are fix in number and there are limitless…
Pranit Kothari
  • 9,721
  • 10
  • 61
  • 137
5
votes
1 answer

Restrictions while kernel is running an ISR routine

What are some of the important do's and dont's inside a kernel mode and ISR Routine ? For example - Is context-switching disabled while running an interrupt handler ? Can a context switch happen when a process is inside a critical section ? What…
4
votes
1 answer

Context switching kernel processes in Linux

Consider the process keventd. It spends all it's lifetime in kernel mode. Now, as far as I know, Linux checks if a context switch is due, while the process is switching from kernel mode to user mode, and as far as I know, keventd will never switch…
Shmoopy
  • 5,334
  • 4
  • 36
  • 72
4
votes
3 answers

Classic asp -- better to do lots of response.write or use <%

I'm editing some legacy code in classic ASP that uses a lot of code like the following: pf "
" pf "
" pf "
Indigenuity
  • 9,332
  • 6
  • 39
  • 68
4
votes
3 answers

Is calling a function considered a context switching?

When I call a function as below void main(void){ Function(); } Is it considered context switching because I save registers before go to the function ?
Amr Tarek
  • 41
  • 3
4
votes
1 answer

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

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…
4
votes
2 answers

Context switch on time interrupt

Quoting the following paragraph from Operating Systems: Three Easy Pieces, Note that there are two types of register saves/restores that happen during this protocol. The first is when the timer interrupt occurs; in this case, the user registers…
FUD
  • 5,114
  • 7
  • 39
  • 61
4
votes
1 answer

Context switching - Is makecontext and swapcontext working here (OSX)

I'm having some fun with context switching. I've copied the example code into a file http://pubs.opengroup.org/onlinepubs/009695399/functions/makecontext.html and i defined the macro _XOPEN_SOURCE for OSX. #define _XOPEN_SOURCE #include…
friartuck
  • 2,954
  • 4
  • 33
  • 67
4
votes
1 answer

Context Switch Overhead in BlockingQueue

Synchronization in BlockingQueue is implemented by Locks while ConcurrentLinkedQueue uses Lock-free algorithm that involves CAS. But my question is regarding context switch overhead. if there are 10 threads de-queuing requests from BlockingQueue…
Faisal Bahadur
  • 498
  • 3
  • 19
4
votes
2 answers

Whats the difference between a process stack and a CPU stack?

I have learned that every single process has its own area/block in the memory that consists of stack, heap, data and text (code) (see this). Now I'm reading stuff about context switching. I read that during a context switch the CPU registers are…
4
votes
2 answers

Are threads from multiple processes actually running at the same time

In a Windows operating system with 2 physical x86/amd64 processors (P0 + P1), running 2 processes (A + B), each with two threads (T0 + T1), is it possible (or even common) to see the following: P0:A:T0 running at the same time as P1:B:T0 then, after…
Jono
  • 1,964
  • 4
  • 18
  • 35
4
votes
1 answer

Monitoring pthread context switching

I would like to monitor the the context switching behavior in a multi-threaded pthread application. In other RTOSes(Micro C OS) I have been able to register a context switch callback for each thread in the application, and then log (or toggle a…
simon
  • 5,777
  • 7
  • 30
  • 36
4
votes
2 answers

Thread pools and context switching (tasks)?

This is quite a general computer science question and not specific to any OS or framework. So I am a little confused by the overhead associated with switching tasks on a thread pool. In many cases it doesn't make sense to give every job its own…
smjpl
  • 41
  • 1
  • 4
4
votes
4 answers

Task Switching in Arm

I am reading the Arm Architecture Reference Manual and I think I have some theoritical questions. Well at first I am confused whether by context switching we mean task switching? Secondly, by having an experience with architecture of Intel 80386 I…
Crusher
  • 41
  • 1
  • 3