Please note that the latency target becomes kernel.sched_min_granularity_ns * (the number of runnable processes). The unit of this parameter is nanoseconds. To prevent this problem, timeslice is guaranteed to become equal or longer than the value of kernel.sched_min_granularity_ns parameter. How about the case that there are so many runnable processes? For example, if the latency target is 10ms and there are 100 runnable processes, does each process's timeslice get just 100us? It seems to be too short since the context switch cost becomes too high in this case. kernel.sched_min_granularity_ns parameter If there are multiple CPUs in the system, the latency target becomes kernel.sched_latency_ns * (1+log2(the number of CPUs)). Here kernel.sched_latency_ns defines the latency target of CFS in nanoseconds. If there are four, these can get 2.5ms per 10ms. For example, if the latency target is 10ms and there are two runnable processes, these can get 5ms per 10ms. Here the timeslice of each process is (latency target)/. CFS tries to give timeslice to all runnable processes once per the latency target. In this case, fair means giving fair share of CPU time to each process.ĬFS has a concept called latency target. If there are two or more runnable processes, CFS divide CPU time to each process as fair as possible. The meaning of the CFS will be explained in the next section. The normal processes belongs to fair scheduling class are scheduled with Completely Fair Scheduler (CFS). The sysctl parameters about fair scheduling class In addition, I'll also describe a brief explanation about each scheduling class. I'll describe the meaning of the sysctl parameters about the above-mentioned two scheduling classes in the following sections. On the other hand, processes called real-time processes (see later) belong to realtime scheduling class. In this article, I call these processes normal processes. Processes belong to fair scheduling class by default. Each scheduling class defines how the processes belonging to it are scheduled. All processes running on Linux belong to one of the scheduling classes. There is a concept called scheduling classes in the Linux kernel. This article is based on Linux kernel v5.0. The description in this article doesn't consider the following things about process scheduling for simplicity. Here I don't tend to explain all parameters, but just cover essential ones. Setting too long will cause poor response to short interactive processes.Ī quantum around 100 m sec is usually reasonable.This article explains the meaning of the Linux's sysctl parameters about the process scheduler and some background knowledge needed to understand it. Too short will cause too many process switches and will lower CPU efficiency. The unlucky last (P10) will have to wait for 5 sec, assuming that all others use their full time slices. If P1 starts executing for first time slice then P2 will have to wait for 1/2 sec and waiting time for other processes will increase. Let the time slice size be set to say 500 m sec and 10 processes are in the ready queue. Thus CPU has to spend 5 m sec on process switching again and again wasting 20% of CPU time. Switching from one process to another requires a certain amount of time to save and load registers, update various tables and lists etc.Ĭonsider, as an example, process switch or context switch takes 5 m sec and time slice duration be 20 m sec. So the choice of time quanta is a very important design decision. Too short quantum causes too many process/context switches and reduces CPU efficiency. When the time quantum is very large, the Round Robin policy becomes a FCFS policy. The performance of time slicing policy is heavily dependent on the size/duration of the time quantum. Long processes may require several quanta. Short processes may be executed within a single time quantum. In this type of scheduling, CPU time is divided into slices that are to be allocated to ready processes. The aim of Round Robin scheduling or time slicing scheduling is to give all processes an equal opportunity to use CPU. It is also termed as Round Robin scheduling. Question: Explain time slicing? How its duration affects the overall working of the system?Īnswer: Time slicing is a scheduling mechanism/way used in time sharing systems.
0 Comments
Leave a Reply. |