Context switch

http://en.wikipedia.org/wiki/Context_switch

A context switch is the computing process of storing and restoring the state (context) of a CPU such that multiple processes can share a single CPU resource. The context switch is an essential feature of a multitasking operating system. Context switches are usually computationally intensive and much of the design of operating systems is to optimize the use of context switches. A context switch can mean a register context switch, a task context switch, a thread context switch, or a process context switch. What constitutes the context is determined by the processor and the operating system.


When to switch?

There are three scenarios where a context switch needs to occur.

Multitasking

Most commonly, within some scheduling scheme, one process needs to be switched out of the CPU so another process can run. Within a preemptive multitasking operating system, the scheduler allows every task to run for some certain amount of time, called its time slice.

If a process does not voluntarily yield the CPU (for example, by performing an I/O operation), a timer interrupt fires, and the operating system schedules another process for execution instead. This ensures that the CPU cannot be monopolized by any one processor-intensive application.

Interrupt handling

Some architectures (like the Intel x86 architecture) are interrupt driven. This means that if the CPU requests data from a disk, for example, it does not need to busy-wait until the read is over, it can issue the request and continue with some other execution; when the read is over, the CPU can be interrupted and presented with the read. For interrupts, a program called an interrupt handler is installed, and it is the interrupt handler that handles the interrupt from the disk.

Clearly, there is a necessity to switch contexts when issuing interrupts - the state of the currently running process must be suspended so that the interrupt handler can be executed.

User and kernel mode switching

When a transition between user mode and kernel mode is required in an operating system, a context switch is not necessary; a mode transition is not by itself a context switch. However, depending on the operating system, a context switch may also take place at this time.

by ingroove | 2008/04/02 03:24 | 트랙백(1) | 덧글(0)

트랙백 주소 : http://ingroove.egloos.com/tb/3685777
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from Withdrawal f.. at 2008/08/22 13:09

제목 : Xanax withdrawal symptoms.
Xanax and withdrawal and seizure. Xanax withdrawal symptoms. Xanax withdrawal symptom....more

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶