Home  >  Article  >  Operation and Maintenance  >  Related introduction to time slices

Related introduction to time slices

巴扎黑
巴扎黑Original
2017-06-23 14:36:102304browse

Time slice (timeslice), also known as "quantum" or "processor slice", is a microscopic segment allocated by the time-sharing operating system to each running process. CPU time (in the preemption kernel: the time from the start of the process until it is preempted). Modern operating systems (such as Windows, Linux, Mac OS In fact, since a computer usually only has one CPU, it is never truly possible to run multiple tasks simultaneously. These processes "look" like they are running at the same time, but in fact they are running alternately. Since the time slice is usually very short (5ms-800ms on Linux), users will not feel it.

Time slices are assigned to each process by the scheduler of the operating system kernel. First, the kernel will allocate equal initial time slices to each process, and then each process will execute the corresponding time in turn. When all processes are in a state where the time slice is exhausted, the kernel will recalculate and allocate time to each process. Film, and so on.

Allocation of time slices

Under normal circumstances, the length of time slices allocated to all processes in a system is not equal, although the initial time slices are basically equal (in Linux systems, The initial time slice is also not equal, but half of the respective parent process), the system calculates the interactivity, interactivity, and per-process presets of each process by measuring the length of time the process is in the "sleeping" and "running" states. The superposition of the static priorities (Nice values) is the dynamic priority. The proportional scaling of the dynamic priority is the length of the time slice to be allocated to that process. Generally, in order to obtain a faster response speed, a process with strong interactivity (ie, tending to be IO consuming) is allocated a longer time slice than a process with weak interactivity (which tends to be processor consuming).

The above is the detailed content of Related introduction to time slices. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn