Presentation on theme: "8.1 Advanced Operating Systems Defeating The Thrashing The RAM is limited. Sometimes, too many processes need large memory allocations and the sum of these."— Presentation transcript:
8.1 Advanced Operating Systems Defeating The Thrashing The RAM is limited. Sometimes, too many processes need large memory allocations and the sum of these allocations is larger than the RAM. Most Operating System schedulers are versions of Round-Robin. Each process will cause a page fault when its turn comes.
8.2 Advanced Operating Systems What Can Be Done? When Linux sees too many page faults, Linux will decide on “thrashing” state. On thrashing state Linux will kill memory consuming processes. –Killing a process is a very aggressive action and can cause unwelcome results. Windows ignores the thrashing and the system will continue to mark time.
8.3 Advanced Operating Systems Can We Do Better? Two level of scheduling like the old medium scheduler used by some operating systems, can improve the solutions. The first level will schedule groups of processes. The second level will schedule the processes within each group. The memory allocation size of each group will be almost equal to the RAM size.
8.4 Advanced Operating Systems The Bin Packing Problem Let P i be a set of processes with memory allocation M i. We need to group the processes such that the sum of M i s in each group will not be bigger than the available RAM. Fewer groups will yield better performance; hence we try to minimize the number of groups. This is exactly the Bin-Packing Problem
8.5 Advanced Operating Systems Using Bin-Packing Opps... The Bin-Packing Problem is NP- Hard. Obviously, the exponential algorithm must not be used in the scheduler. –The scheduler must be fast. There are some polynomial approximations solving this problem. Which one is the best? –The answer will be the “First-Fit” approximation, but should be proved.
8.6 Advanced Operating Systems “First Fit” “First Fit” algorithm: –Sort the items. –Try to insert each item to an existing bin. –If there is no room for this item, open a new bin. “First Fit” will never take out an item after it has been put in a bin.
8.7 Advanced Operating Systems Group Time Slice The group time slice should be long enough in order to prevent thrashing. Sometimes the groups are not equal. –Indeed, a group contains even just one process is possible. Set the time slice duration according to the group size.
8.8 Advanced Operating Systems Shared Memory Usually processes with shared memory allocations have the same shared allocation size; hence no need for a special action.
8.9 Advanced Operating Systems Interactive Processes Interactive processes need fast response time. Waiting for their group can be an irksome delay. The kernel puts the interactive processes in every group; thus they will always be running. However, in order to be fair, the time slice duration of the interactive processes should be diminished. –The time slice of the interactive processes is divided by the numbers of the bins.
8.10 Advanced Operating Systems Real Time Processes Real time processes are similar to interactive processes. They cannot wait for their group to be activated. The solution is similar. The kernel puts real time processes in every group. The only difference is the time slice, which is obviously must not be diminished.
8.11 Advanced Operating Systems Priority It might happen that the highest priority processes will be in one group, whereas the lowest priority processes will be in a second group. The time slice is set according to the processes’ average priority within each group.
8.12 Advanced Operating Systems No. of Swaps and Execution Time Synthetic Benchmark
8.13 Advanced Operating Systems SPEC No. of Swaps and Execution Time
8.14 Advanced Operating Systems Time Slice Duration
8.15 Advanced Operating Systems Selecting an Approximation
8.16 Advanced Operating Systems Conclusions The medium-term scheduler drastically reduces the thrashing overhead. No decline in performance when there is no thrashing. Can easily installed on any Linux machine. The code is free and can be obtained at: http://www.cs.biu.ac.il/~reubenm/