Login with Facebook

Everything you need to know about Virtual memory

Virtual memory consists of virtualizing the address space. It is an operating system mechanism that requires hardware support. Here we will discuss what the virtual memory is and how it works. Let’s delve into it!


What is Virtual Memory?


Virtual memory is a mechanism of the operating system that allows running programs larger than RAM. It gives the illusion to the processes of having potentially unlimited space. The immediate consequences are these:


· We can have processes larger than the free space in RAM.

· We can process data larger than the free space in RAM.


It looks like witchcraft because we know that everything that needs to be processed must reside in primary memory. In fact, the thing that makes virtual memory brilliant is that we use the disk as if it were RAM.


In reality, it is not really so, instead, it is not entirely correct.

We have to say that we use secondary memory to temporarily support pieces of processes/data that we do not need at this time, and that probably will not serve us for a while.


Imagine this scenario:


1. You must perform a process.

2. Load only the first pages in RAM.

3. The rest allocate them on the disc.

4. As the process requires more pages, you take them from the disk and swap them to RAM.

Or:

1. You have some RAM processes.

2. You have to load another process, but you have no free space.

3. Take a piece of another process, whose pages haven't been used for a long time.


1. In the newly freed space, go to load the first pages of the new process.

A beautiful saved, right?


We have just introduced a term: swap, which indicates a transfer between primary and secondary memory more precisely:


·     Swap in disk -> RAM.

·     Swap out RAM -> disk.


Addressing in Virtual Memory (Segmentation on Pagination)


Now that we know what virtual memory is let's see how addressing works.

Since we use RAM and disk a bit in the same way, we should have an address that takes this property into account. In fact, virtual addresses are used both to address pages in RAM and on disk.


 A virtual address is a triple formed by <segment number. page number. offset>

Below this address, we have the two familiar levels of segmentation and paging.


Line segment table : < control bit. length. base of the segment>.


 Row page table : < P. M. control bit. frame number>.


We realized that page addressing is now slightly different. In particular, we have added two bits Ped M.


· P (present): indicates that that page is currently in RAM, and not on disk.

· M (modified): indicates that the page has been modified.


Before continuing with the translation of the addresses, it is smart to remember that:


· Each process has its own table of segments, which directs points of leaving and length of its various segments.


· Each process has various page tables, which address various pages.

· Each segment addresses a specific page table.


Well, let's see the general scheme of addressing.


 If you find something out of place, give one back to the three things we remembered a moment ago.

It may be useful to have a commentary on the image just seen:

1. We have a virtual address, therefore: a segment number, a page number, and an offset.

2. We also have the pointer to the segment table for the process.

3. Let’s take the segment table, and go to the line denoted by segment number

4. In that line we find the address of the page table for that segment.

6. Let's take that page of the pages, and go to the line denoted by 

 page number. In that line, we find the number of frames.

7. Let's take the RAM and go to the address denoted by that number of frames, and move to it based on the offset.

 

Page Swap Policies

Ok, we know what swap is. Imagine now that you have a situation where the system is in a constant state of swap in and out. This phenomenon is called thrashing. Since swap is expensive, with thrashing, we are going to devastate system performance heavily. We realize that there is always the general principle of the locality that winks at the corner.


Fetch Policy (upload policies)


This type of Policy decides how to load pages into RAM.

When there is a reference to a page not present in memory, we have a page fault, which triggers the fetch mechanism, or * replacement * (which we will see shortly).

We have two types of fetch policies:

·     On-Demand Paging: load page as soon as it is referenced, initially causes many page faults.

· Preparing: loads several contiguous pages (locality principle).

· Replacement Policy (replacement policies)


· Decide which page to replace, if necessary.


 These policies are quite important, in fact, we have different algorithms to implement them. The quality of an algorithm is determined by the number of page faults that it triggers.


· The replaced pages are then inserted into a page buffer, which typically divides between modified and non-modified pages.


 After a page fault, before loading the page from the disk, the memory manager checks its presence in the page buffer.


· Let's look at these five-page replacement algorithms.


· OPT (Optimal Replacement)


· It is a utopian optimal replacement of the pages.

 It is not feasible because it involves replacing the page that will be used later, which we cannot know.


· LRU (Least Recently Used)

· Replaces the recently used less page.

 It needs a label that represents the time of use.


· FIFO (First in - First Out)


· Replaces the page in memory for the longest time. It's like a circular buffer.

 Simple and cute, too bad that it does not take advantage of the principle of locality. So it sucks us.


Clock:


We call it a clock because we can represent it graphically as a clock in which:


· Instead of numbers we have pages.


· Each page is assigned a use bit (or reference bit) with values ​​{0, 1}

· The hand acts as a pointer.


From a general point of view, we can say that the clock algorithm works like this:


· The pointer points to the oldest page.

· Initially the use bit is 0.

· When referencing a pageVirtual memory, its bit increments to 1. The bit of the pages encountered by the pointer (hand) up to the referenced page is set to 0.

· The page to be replaced is the first that the hand encounters with a 0 use bit.

This algorithm is also called second chance because pages with use bit 1 are given a second chance to remain in memory.


Comments




Send Comment

Need a custom
essay?

We will write it for you.
Order now

Free Essay Examples

Free essays:

All you need to know about the ACA Code of ethics
Architecture and Democracy: An Introduction
Architecture and Democracy: Democratic Values
Architecture and Democracy: Democratic Procedures
All You Need to Know About a Synthesis Essay
An essential guide to understanding Film Theory
Application of Artificial Intelligence in Cyber Security
Applications of electrical engineering
Augmented reality: what it is, how it works, examples
Advantages And Disadvantages Of Social Networking
All you need to know about Cryptography
Applications of astrophysical science
All you need to know about architecture engineering
Applications of geological engineering
Artificial intelligence and medicine: an increasingly close relationship
An insight into Computational Biology
ACA code of conduct
A Rose for Emily
Applications of Mathematics in daily life
Architecture mistakes to avoid
All you need to know about Toxicology
All you need to know about Holistic Medicine
All you need to know about linguistics
An introduction to Linguistics and its subfields
All you need to know about Anxiety disorder
All you need to know about Drones
A Brief Insight into Political Science
Assumptions related to feminism
Biomedical engineering trends to look out for
Bionic Limbs and Technology: Advancements Improving Patients' Lives
Bipolar disorder: Symptoms, causes, diagnosis and treatment
Biochemistry of neurotransmitter
Brain-Computer Interface systems with EEG signals
Consequences of racial discrimination in urban housing development
Cryptocurrency: Advantages and Disadvantages
Character Archetypes: The Good
Character Archetypes: The Bad
Contemporary art trends
Commonly Confused Words
Commonly Confused Words: Part 2
Data Visualization: What it is and why it matters?
Data Science: Fundamental tools for data analysis
Different forms of dance you should know about
Digital Imaging: What Is It?
Dynamic Systems Modeling with Machine Learning
Eat To Live or Live To Eat
Everything you need to know about WiMAX
Everything you need to know about Data Science
Everything you need to know about Virtual memory
Entrepreneur trends to know about
Film styles and the types of styles for shooting a film
Famous African American literature authors
How to Write a Personal Essay
Housing Needs in America
How to Write a Description Essay
How to Create an Excellent Scholarship Essay?
How to write a cause and effect essay
How to Hire the Best Essay Writing Service Provider?
How to Write a College Application Essay?
How to get the most out of your English lectures
How to write Expository Essay
How to succeed in your psychology class?
How to Write an Academic Essay in the Shortest Time?
History of Journalism
How Different Sectors are Using Artificial intelligence (AI)
How to write an informative essay
How to deliver persuasive essays?
How to Give a Convincing Presentation
How to write an essay on leadership?
Historical Art Still Around Today
Humanoid robot: what it is, how it works and price
History of Chemistry
Healthcare Advanced Computer Power: Robotics, Medical Imaging, and More
Healthcare AI: Game Changers for Medical Decision-Making and Remote Patient Monitoring
How to understand different types of English
How to Cope with Chronic Pain
How African American choreographers and dancers have influenced American dance
How mobile robot can do in logistics or in production
How To Become a Successful Entrepreneur
History of the Philosophy of Feminism
Introduction to Urban Studies
Importance of dance in education
InMoov: how to build an open source humanoid robot
Importance of KYC verification to making the Blockchain secure
Importance of Rhythm
Importance of dance student evaluation
I/O control methods -types and explanations
Identity theft: what to do?
Know about the history of science
Know about the different forms of traditional African dances
Latest dance trends
Latest technology trends
Modern sociology trends you should know about
Modern Art that the Past Would Have Scorned
Modern Art that the Past Would Have Scorned, Part 2
Memory Management in an Operating System
Misconceptions About the Word “Introvert”
Major healthcare trends
Nuclear fusion: What it is and how it works?
Neural networks: what they are and what they are for
Robotic Integration into Our Lives: Now and the Future
Role of a neuroscientist
Risk management, meaning, and importance for companies
Role of gender studies
Role of a digital artist
Should You Start a Career Or Enter University At 18?
Smoking Should Be Banned
Should You Go Digital?
Standard finance terms to know about
Social robots
Schizophrenia - a rare psychiatric illness | Essay
The Looming Energy Crisis in America
Top benefits of performance-based engineering
The More Languages You Know, The More Times You Are a Man
Things to consider while writing an Argumentative Essay
Top Ways to Improve Your Academic Writing Skills
Tips to Excel in Creative Writing
The origins of films in the early 19th century
Top career options in Architecture
The Elevator Pitch
Top finance trends 2020
The basic Structure and functionality of robots
The Way to Success
The election system of the President in the United States of America
Two-party System in United States of America
Top trends in urban design
The history and theory of African American filmmaking
Top benefits of creative writing
Tinnitus Guide: Common Symptoms and Treatment Options
The language of dance
The digital image processing management
Top famous politicians of the World
Top methods of political science!
The history of the feminist movement
Understanding the sociology of Race & Ethnicity
Urban planning in the US
Virtual reality, what it is and how it works
Various theoretical perspectives of sociology
What is a Definition Essay?
What are diagnostic essays?
What is the relation between art structural engineering?
What is a Narrative Essay
What are robotics and intelligence systems?
What are the benefits of studying health sciences?
What is artificial intelligence and why it matters?
What is comparative Literature?
Why study neuroscience
What is Wi-Fi and how does it works
What is French history famous for?
What are Humanistic Studies?
What is covered in Biophysics?
What is modern journalism?
What is Virtualization? Benefits & Applications
What are modern public relations?
What is plasma physics?
What is teacher preparation?
What is rapid prototyping for 3D printing?
What is contemporary European Politics?
Why should you learn American Ballet?
What is engineering physics?
What is the purpose of African American Literature?
Ways to learn the Rhythm
What is digital art used for?
What are Enzymes and how do they work
Who is the father of political science?
Why Study Political Science - Job?
What is the Philosophy of Feminism?
What is a quantum computer?
Ways B2B Startups Streamline Their Conversion Strategies
Why do biomedical signals need processing?
4 Facts about Origin of Mathematics!