search
HomeWeb Front-endHTML TutorialMemory management paging and page fault calculation_html/css_WEB-ITnose

1. What is a missing page?

To put it bluntly: Page fault is defined as all memory blocks are initially empty, so the page used for the first time will generate a page fault, that is, if the page number to be entered does not exist in the memory, it will occur. Missing pages. After understanding this, it becomes easier to solve the problem of page missing calculation.

2. First-in, first-out scheduling algorithm (FIFO)

This scheduling algorithm always eliminates the latest page entered into the main memory. This scheduling algorithm is very simple. It arranges the pages into a page number queue in the order in which they are loaded into the main memory. Whenever a page fault is entered, the page that enters the earliest is eliminated.

For example: For example, the page numbers to be accessed in sequence are: 0 1 2 3 2 1 3 2 5 2 3 6 2 1 4 2. Now there are only three main memories available. If FIFO scheduling is used, Please simulate the scheduling process and calculate the number of page fault interrupts?

0 enters, a page fault interrupt occurs (1 time), the page number in the memory at this time: 0
1 enters, a page fault interrupt occurs (1 time), the page number in the memory at this time: 01
2 enters, a page fault interrupt occurs (1 time), the page number in the memory at this time: 012
3 enters, 0 is eliminated, a page fault interrupt occurs (1 time), 3 replaces the position of 0, and the memory Page number in: 123
2 Enter, there is no page fault interrupt, because page number 2 already exists in the memory, the page number in the memory is still: 123
1 Enter, page number 1 exists in the memory, no A page missing interrupt occurs. At this time, the page number in the memory is: 123
3Enter, the same as above, no page missing interrupt occurs, the page number in the memory is: 123
3Enter, the same as above, no page missing interrupt occurs , the page number in the memory is: 123
5 enters. At this time, the longest time for 312 is: 1, so 5 replaces 1, and a page fault interrupt occurs (1 time). At this time, the page in the memory No.: 235
6Enter, there is no page missing interrupt, the page number in the memory: 335
6Enter, there is a page missing interrupt (1 time), the eliminated page is No. 2, the page number in the memory is 356
2 Enter, a page missing interrupt occurs (1 time), the eliminated page number is 3, the page number in the memory is 5662
1 Enter, a page missing interrupt occurs (1 time), the eliminated page number is 5 No., the page number in the memory is 621
4 enters, a page fault interrupt occurs (1 time), the eliminated page number is 6, the page number in the memory is 214
2 enters, no page fault interrupt occurs , the page number in the memory is 214

Therefore, if the first-in-first-out scheduling algorithm is used, a total of 8 page fault interrupts will occur, and the memory simulation situation is as follows:


Enter

Time

0

1

2

2

1

2

2

2

1

2

Morning

0

0

0

1

1

1

1

1

2

2

2

2

1

1

2

2

2

2

2

2

1

1

Late

2

1

Whether

missing page

is

is

is

Yes

Not

No

It’s not

It’s

It’s not

It’s not

is

is

Yes

Yes

No


*The red number is the latest page number entered into the memory
For the first-in-first-out simulation process, it is not difficult to find the following characteristics:
1. First If it enters the memory for the first time, there must be a page fault;
2. If there is no page fault, the consecutive columns are the same;
3. The eliminated page is the one that has stayed in the memory the longest;

3. The most recently unused scheduling algorithm (LRU)

The most recently unused scheduling algorithm believes that pages that have been frequently used recently may be accessed soon, so they cannot be called out. On the contrary, if there are pages that have not been visited in the past period, they may not be visited in the near future. Therefore, when you need to load a new page, you should select the page that has not been used for the longest time in the recent period.

Still taking the above example, using LRU scheduling,
First, 0 enters, and the page is missing (1 time). At this time, the page numbers in the memory are in the order of frequency of use: 0
1 Enter, page missing (1 time), the page numbers in the memory are in the order of frequency of use: 01
2 Enter, page is missing (1 time), the page numbers in the memory are in the order of frequency of use: 012
3Enter, page missing (1 time), the longest unused page number is 0, replaced by 3. At this time, the page numbers in the memory are in the order of frequency of use: 123
2Enter, no page missing, At this time, the page numbers in the memory are in the order of frequency of use: 132
1 Enter, there is no page shortage, the page numbers in the memory are in the order of frequency of use: 321
3 Enter, there is no page shortage, and the memory is at this time The order of page number usage frequency: 213
2 Enter, there is no page missing, the page number usage frequency order in the memory at this time: 1332
5 Enter, page missing (1 time), the longest unused page The page number is No. 1 and is eliminated. At this time, the order of page number usage frequency in the memory is: 325
3Enter, there is no page shortage. At this time, the order of page number usage frequency in the memory is: 352
3Enter , there is no page missing. At this time, the page number usage frequency sequence in the memory is: 523
6Enter, page missing (1 time), at this time the page number usage frequency sequence in the memory is: 236
2 Enter, There is no page shortage. At this time, the order of page number usage frequency in the memory: 362
1 enters, page missing (1 time), the page number that has not been used for the longest time is 3, at this time, the order of page number usage frequency in the memory : 621
4 entry, page missing (1 time), the page number that has not been used for the longest time is 6, the order of page number usage frequency in the memory at this time: 214
2 entry, no page missing, the memory at this time The order of page number usage frequency: 142

Therefore, using the most recent scheduling algorithm that has not been used for a long time, its number of page misses: 8 times

Its scheduling simulation in memory is as shown in the table below Display:

Use

frequency

0

1

2

2

1

2

2

1

Long time

No use

0

0

0

1

1

2

1

2

2

1

1

1

2

2

1

2

2

2

1

Recently

Used

2

2

1

2

1

2

Yes

Missing page

Yes

Yes

Yes

Yes

No

No 🎜>Not

Not

不是

不是

不是

Yes

Yes

No


四、小结

  多拿笔画画~~~


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
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.