Time slice

Introduction

Time slice (timeslice), also known as "quantum" or "processor slice" is a time-sharing operating system A microscopic period of CPU time allocated to each running process (in the preemptive kernel: the time from when the process starts to run until it is preempted). Modern operating systems (such as: Windows, Linux, Mac OS X, etc.) allow multiple processes to run at the same time-for example, you can use a browser to browse the web and download files while opening a music player to listen to music. In fact, although a computer may usually have multiple CPUs, the same CPU can never truly run multiple tasks at the same time. When only one CPU is considered, these processes "look like" running at the same time, but in fact they are running alternately. Because the time slice is usually very short (5ms-800ms on Linux), users will not feel it.

Time slices are allocated to each process by the scheduler of the operating system kernel. First, the kernel allocates an equal initial time slice to each process, and then each process executes 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 for each process Film, so back and forth.

Time slice allocation

Under normal circumstances, all the processes in a system are allocated to the time slice length is not equal, although the initial time slice is basically the same (in the Linux system , The initial time slices are not equal, but half of the respective parent process), the system calculates the interactivity, interactivity and each process of each process by measuring the length of time the process is in the "sleep" and "running" state The superposition of the preset static priority (Nice value) is the dynamic priority, and the dynamic priority scaling 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 interaction (that tends to be IO-consuming) is allocated a longer time slice than a process with weak interaction (that tends to be processor-consuming).

See

  • Preemptive multitasking

Related Articles
TOP