Operating System Fundamentals



Download 2.34 Mb.
View original pdf
Page44/66
Date06.03.2023
Size2.34 Mb.
#60834
1   ...   40   41   42   43   44   45   46   47   ...   66
OperatingSystemFundamentals
best answers from c, Lesson 2 C# Windows Forms
Using FIFO

Sequence
1
2
1
3
1
4
1
5
2
3
2
4
1
5
Hit?
N Nb Yb N
Y
N N N N Nb Yb N N Nb Frame 1

1 1
1 1 4 4 2 2
2 1
Frame 2
2 2 1 1 3 3 5
Frame 3
3 3 5 5 4
Hit Ratio
3/14
Using the First In First Out (FIFO) policy, we end up with a total of only three hits out of fourteen attempts to send information between the CPU and RAM.



Operating System Fundamentals
61
Using LRU:

Sequence
1
2
1
3
1
4
1
5
2
3
2
4
1
5
Hit?
N Nb Yb N
Y
N
Y
N N Nb Yb N N Nb Frame 1

1 1
1 1
1 3 3 5
Frame 2
2 2 4 4 2 2
2 1
Frame 3
3 3 5 5 4
Hit Ratio
4/14

Using the Least Recently Used (LRU) replacement policy, we end up with a total of four hits out of fourteen attempts to send information between the CPU and RAM.


Using LFU:

Sequence
1
2
1
3
1
4
1
5
2
3
2
4
1
5
Hit?
N Nb Yb N
Y
N
Y
N N Nb Yb N
Y
N
Frame 1
1 1
1 1
1
Frame 2
2 2 4 4 2 2
Frame 3
3 3 5 5 3 5 4 4 5
Count
1 1
2 1
3 1
4 1
1 1
2 1
5 1
Hit Ratio
5/14
Using the Least Frequently Used (LFU) replacement policy, we end up with a total of five hits out of fourteen attempts to exchange information between the CPU and RAM. In this example, the
LFU replacement policy has resulted in the highest hit ratio, and the least number of page faults. That means that using the LFU replacement policy will result in the least amount of times swapping pages between RAM and the page file, and the lowest overall processing time.


Thrashing in Virtual Memory
The use of virtual memory has both benefits and drawbacks. The main benefit is that it artificially increases the overall amount of memory available for the execution of processes. However, as we have seen, swapping pages between RAM and virtual memory slows down the overall processing time. It takes much more time to locate and retrieve data from a hard disk than it does from RAM. When your computer spends too much time swapping pages between RAM and the page file, we call this condition thrashing. Thrashing not only results in longer processing time, it also leads to increased wear and tear on your hard disk. Normally, your computer only reads data from your hard disk when you are loading it into memory to be used. Your computer normally only writes data to your hard disk when you are finished with it, and you want to save it.


Operating System Fundamentals
62
What Causes Thrashing
Thrashing is typically caused when you have too many processes running at the same time. All of these processes will compete for the limited amount of physical memory installed in your computer. If your computer is thrashing, your applications may stop responding (or run very slowly. At the same time, you may notice your hard drive light blinking (and you may hear the hard drive spinning. There are really only two ways to correct thrashing
1. Kill (stop) some of the processes (temporary solution)
2. Install more RAM Unit Summary The memory manager has the responsibility of allocating memory resources to processes and threads as needed. This task includes assigning memory as needed and retrieving information from memory when it is needed by the CPU. The memory manager also has the responsibility for managing available memory as efficiently as possible to make sure that as much memory as possible is actually usable by processes, and to make sure that processes can be executed as quickly as possible. The three main strategies used to assign memory spaces are called Best Fit, Worst Fit and First Fit. Most modern operating systems also use virtual memory, which uses part of another storage device to act as extra RAM. The memory manager must handle swapping pages (chucks of data and process code) between main memory (RAM) and virtual memory (storage device. The page table is used to keep track of the location of pages in RAM, and if a page is requested that is not located in RAM a page fault will be generated. The memory manager must find the requested page in virtual memory, load it into RAM, and re- execute the instruction. There are five main strategies (called policies) that are used the manage page swapping between RAM and virtual memory. The memory manager must use the most appropriate strategy to minimize the number of page faults that are generated, thus minimizing the overall time needed to execute a process. When too many processes are competing for main memory, and too many pages are being swapped between RAM and virtual memory, a condition called thrashing is created. Thrashing can cause undue wear and tear on a hard disk, and increases the amount of time needed to execute an instruction set. The memory manager tries to minimize thrashing, but the only real solutions are to either reduce the number of running processes or add more RAM to the system.

Download 2.34 Mb.

Share with your friends:
1   ...   40   41   42   43   44   45   46   47   ...   66




The database is protected by copyright ©ininet.org 2024
send message

    Main page