Operating Systems 2 - Memory Manager

SMKS
18 Jun 201308:53

Summary

TLDRSean's tutorial explores various memory management schemes, starting with the inefficient single user contiguous allocation, moving to fixed and dynamic partitions, and then to the more efficient paged memory allocation. He discusses demand paging, segmented memory allocation, and their combination, emphasizing virtual memory's ability to extend beyond physical RAM limits. The tutorial highlights the evolution of memory management, aiming to improve CPU efficiency and job processing times.

Takeaways

  • πŸ˜€ The tutorial introduces three old memory management schemes: single user contiguous, fixed partitions, and dynamic partitions.
  • πŸ”„ Single user contiguous memory management was inefficient as it required the entire memory space for a single job and was impractical for modern systems.
  • πŸ“ Fixed partitions allowed multiple jobs to be stored in memory but had static sizes, requiring a system reboot to change, leading to inefficiency.
  • πŸ”„ Dynamic partitions improved on fixed partitions by allocating memory based on job requests, but still required contiguous blocks and efficient allocation strategies.
  • πŸ“š The script discusses allocation strategies like first fit and best fit, which have different trade-offs in terms of memory waste and processing speed.
  • πŸ—‚οΈ Virtual memory is introduced as a solution to overcome the limitations of contiguous memory storage, allowing for more efficient memory usage.
  • πŸ“‘ Paged memory allocation divides jobs into equal-sized pages, which can be stored in any available page frame, simplifying memory management.
  • πŸ—ΊοΈ Demand paging is a variation of paged allocation where pages are loaded into memory only when needed, improving efficiency further.
  • πŸ”„ Page replacement policies like FIFO, LRU, LFU, and MRU are crucial for managing which pages to keep in memory and which to swap out.
  • πŸ“ˆ Segmented memory allocation breaks jobs into variable-sized segments based on the program's structure, allowing for more logical memory usage.
  • πŸ”„ Combined segmentation and paging allocation offers the benefits of both approaches, with the addition of segment map and page map tables for better control.
  • πŸ’Ύ Virtual memory allows systems to exceed physical RAM capacity by using the hard drive as backup memory, albeit at a slower speed but with increased flexibility.

Q & A

  • What was the first memory management scheme discussed in the tutorial?

    -The first memory management scheme discussed was single user contiguous memory management, which was not very efficient as it required a single job to reserve the entire memory space.

  • Why was the single user contiguous memory management scheme considered impractical for modern operating systems?

    -It was considered impractical because it would be very slow to process all of the jobs on demand, and if the job size was larger than the available RAM, it could not be executed.

  • What is the main advantage of fixed partitions over single user contiguous memory management?

    -Fixed partitions allow allocated partitions to contain more than a single job at one time, improving efficiency over single user contiguous memory management.

  • What is the main disadvantage of fixed partitions in memory management?

    -The main disadvantage is that the sizes of these partitions are static, meaning they cannot be changed unless the system is rebooted, which is not ideal for dynamic job processing.

  • How does dynamic partitioning improve upon fixed partitioning?

    -Dynamic partitioning improves by allocating only as much memory as jobs request when they are loading for processing, thus avoiding memory waste and not requiring a system reboot to change partition sizes.

  • What are the two methods for allocating jobs to available partitions in fixed and dynamic partitions?

    -The two methods are first fit, which finds the first partition with sufficient storage space, and best fit, which looks for the smallest partition to minimize memory waste.

  • What is the purpose of the paged memory allocation scheme?

    -The purpose of paged memory allocation is to divide the job into equal-sized parts, allowing these parts to be stored in any available page frame in the main memory, improving efficiency over contiguous block storage.

  • What are the three tables used to keep track of page locations in paged memory allocation?

    -The three tables are the job table, the page map table, and the memory map table, which keep track of various aspects of page locations and statuses.

  • How does demand paging differ from paged memory allocation?

    -Demand paging is similar to paged memory allocation, but the main difference is that pages are loaded on demand, meaning they are only brought into memory when they are actually needed.

  • What is the role of a page replacement policy in demand paging?

    -A page replacement policy determines which pages to replace when the memory is full, using algorithms such as first-in first-out, least recently used, least frequently used, and most recently used.

  • What is the main idea behind segmented memory allocation?

    -Segmented memory allocation splits the job into separate segments that reflect the nature and structure of the code, allowing for more logical and efficient memory usage compared to paged allocation.

  • How does the final memory allocation scheme combine the benefits of segmentation and paging?

    -The final scheme is a mixture of segmented and demand paging memory allocation, using both the segment map table and page map table, along with additional authority information, to offer the logical benefits of segmentation and the physical benefits of paging.

  • Why is virtual memory considered beneficial despite the increased processing cost?

    -Virtual memory is beneficial because it allows the system to exceed the physical memory capacity by using the hard drive as a backup memory, acting as an extension to the RAM and providing a more efficient service to the CPU for handling jobs.

Outlines

00:00

πŸ’Ύ Memory Management Evolution

Sean introduces various memory management schemes, starting with the single user contiguous method, which was inefficient due to the need for a job to occupy the entire memory space. This was followed by fixed partitions, allowing multiple jobs to be stored but with static sizes, leading to inefficiencies. Dynamic partitions improved on this by allocating memory based on job requests, but both required complex allocation strategies. The script then delves into virtual memory concepts, starting with paged memory allocation, which divides jobs into equal-sized pages and uses page frames in memory, simplifying the process but adding complexity in tracking page locations through various tables. The explanation covers job table, page map table, and memory map table functions.

05:02

πŸ”„ Advanced Memory Allocation Techniques

The script continues with an exploration of demand paging, where pages are loaded into memory only when needed, and introduces the page replacement policies that determine how pages are managed in memory. It then discusses segmented memory allocation, which breaks jobs into segments reflecting the code's structure, and uses a segment map table for allocation. The final scheme combines segmented allocation with demand paging, offering logical and physical benefits but at the cost of increased complexity. The advantages of virtual memory, such as extending beyond physical RAM capacity using the hard drive as backup memory, are highlighted. The script concludes with a teaser for the next episode on process management and a call to action to subscribe to the S MKS Channel.

Mindmap

Keywords

πŸ’‘Memory Management

Memory management is the method by which an operating system allocates and deallocates memory to programs during their execution. It is central to the video's theme, as the script discusses various schemes for managing memory efficiently. The video script describes the evolution from single-user contiguous memory to more complex schemes like paging and segmentation.

πŸ’‘Single User Contiguous Memory

This refers to the first memory management scheme where a single job would reserve the entire memory space, making it inefficient as it required clearing memory after each job and could not handle jobs larger than available RAM. It's an impractical scheme for modern operating systems, as mentioned in the script, due to its inflexibility and inefficiency.

πŸ’‘Fixed Partitions

Fixed partitions represent a memory management scheme that allows multiple jobs to be stored in the memory by dividing it into static, non-resizeable partitions. The script mentions that this scheme improved upon single-user contiguous memory by allowing more than one job at a time but was limited by the static nature of partition sizes.

πŸ’‘Dynamic Partitions

Dynamic partitions are a memory management technique where the size of the memory allocated to a job is flexible and only as much as the job requests. This concept is highlighted in the script as a significant improvement over fixed partitions because it reduces memory waste, although it introduces complexity in allocation and deallocation.

πŸ’‘First Fit

First fit is an allocation strategy mentioned in the script where the memory manager finds the first partition with sufficient space for a job, regardless of potential memory waste. It's a simple method but may not be the most efficient due to the lack of consideration for memory utilization.

πŸ’‘Best Fit

Best fit is another allocation strategy described in the script, where the smallest partition that can accommodate a job is selected. This method aims to minimize memory waste but can lead to slower performance due to the time taken to find the best fit.

πŸ’‘Paged Memory Allocation

Paged memory allocation is a scheme where the job is divided into equal-sized parts called pages, and main memory is divided into page frames. The script explains that this method allows for more efficient memory use as pages can be loaded non-contiguously, but it also increases complexity due to the need for tracking page locations.

πŸ’‘Demand Paging

Demand paging is a concept where pages are only loaded into memory when they are needed, rather than loading the entire program at once. The script illustrates that this approach is similar to paged memory allocation but optimizes memory usage by loading pages on demand, managed through a page map table with additional status columns.

πŸ’‘Segmented Memory Allocation

Segmented memory allocation breaks down a job into separate segments that reflect the program's structure, such as functions or subroutines. The script explains that this method allows for more logical organization of code and uses a segment map table to track the varied-sized segments in memory.

πŸ’‘Segmentation and Paging

This refers to a combination of segmented and demand paging memory allocation, as described in the script. It offers the logical benefits of segmentation with the physical benefits of paging, using both segment map and page map tables, and includes authority information for read, write, and execute operations.

πŸ’‘Virtual Memory

Virtual memory is the concept of using both physical memory (RAM) and disk space to give an application the impression it has more memory than is physically available. The script highlights virtual memory as a solution to exceed memory capacity by using the hard drive as a backup memory, which is slower but extends the usable memory.

Highlights

Introduction to memory management schemes and their evolution.

Single user contiguous memory management was inefficient and impractical for modern systems.

Fixed partitions allowed for multiple jobs in memory but had static sizes.

Dynamic partitions improved upon fixed partitions by allocating memory based on job requests.

Allocation schemes such as first fit and best fit were introduced for partition allocation.

Paged memory allocation divides jobs into equal-sized parts, improving efficiency.

Demand paging loads pages into memory only when needed, optimizing memory usage.

Page replacement policies like FIFO, LRU, LFU, and MRU are crucial for system efficiency.

Segmented memory allocation breaks jobs into segments reflecting the code's structure.

Segment map tables are used to manage the allocation of variable-sized segments.

Combined segmented and demand paging offers logical and physical memory management benefits.

Virtual memory allows exceeding RAM capacity by using the hard drive as backup memory.

The operating system's increased processing cost provides more efficient CPU job handling.

Sean's tutorial series will continue with the process manager in the next episode.

Importance of subscribing to the SMKS Channel for further educational content.

Overview of memory management's impact on performance and efficiency in operating systems.

Transcripts

play00:11

hello my name is Sean and in this

play00:14

tutorial we shall begin with the memory

play00:16

manager and look at three old schemes of

play00:19

memory management single user contiguous

play00:23

was the first scheme of memory

play00:25

management and it wasn't very efficient

play00:28

in terms of performance a single job

play00:31

would reserve the entire memory space

play00:33

this job would be processed and then the

play00:36

memory was cleared allowing the next job

play00:38

to be loaded if the job size was larger

play00:41

than the space available in the RAM it

play00:44

could simply not be executed this scheme

play00:48

is considered impractical for today's

play00:50

modern operating systems as it would be

play00:52

very slow to process all of the jobs on

play00:55

demand but what if you wanted to store

play00:58

two or three jobs in the memory this is

play01:01

when fixed partitions came along

play01:04

allowing allocated partitions to contain

play01:07

more than a single job at one time all

play01:10

of the partitions were stored in a

play01:12

partition memory table to keep track of

play01:15

partition usage the sizes of these

play01:18

partitions were static

play01:20

meaning they could not be changed unless

play01:23

the system was rebooted so you could see

play01:26

how this would be a problem a dynamic

play01:29

solution was necessary to avoid having

play01:31

to reboot the computer every time you

play01:34

wanted to process a job a dynamic

play01:37

partitions available memory is still

play01:40

kept in contiguous blocks but jobs are

play01:43

only given as much memory as they

play01:45

request when they are loading for the

play01:47

processing this has proven a significant

play01:50

improvement over fixed partitions

play01:52

because memory is not wasted in the

play01:55

partition unfortunately this is not a

play01:59

complete solution both fixed and dynamic

play02:02

partitions need some way to allocate

play02:05

jobs to the available partitions there

play02:08

are two ways to do this the first fit

play02:10

quite simply finds the first partition

play02:13

that has sufficient storage space not

play02:15

taking into account how much memory

play02:17

could be wasted in the allocated

play02:19

partition the best fit first looks for

play02:22

the smallest partition was

play02:24

putting in more space for other jobs

play02:26

resulting in slower performance but

play02:29

better efficiency so when a job has

play02:33

completed processing it is then removed

play02:35

from memory also known as D allocation

play02:39

with a fixed partition this is fine it

play02:42

is simply cleared but when using a

play02:44

dynamic partition it gets more complex

play02:47

to free up memory as it tries to join

play02:50

together adjacent blocks so looking at

play02:53

these simple allocation schemes we can

play02:56

see there are still problems each one

play02:59

required the memory manager to store the

play03:01

entire program in the main memory at

play03:04

contiguous locations we need to find a

play03:07

way to avoid having to keep the whole

play03:09

program in memory to run and the

play03:12

restriction of storing the program's

play03:14

contiguously what if we could divide the

play03:17

jobs into separate smaller chunks we can

play03:21

virtual memory is the solution and we

play03:24

shall look at the evolution of four

play03:26

memory allocation schemes let us start

play03:30

with paged memory allocation allowing us

play03:33

to divide the job into equal sized parts

play03:36

the sections of a disk are known as

play03:38

sectors or blocks and the sections of

play03:41

main memory are known as page frames

play03:44

before executing a program the memory

play03:48

manager makes some preparations first it

play03:51

determines how many pages are in the

play03:53

program and then it locates enough empty

play03:57

page frames in the main memory so that

play03:59

it can pass all the pages into them the

play04:02

adjacent memory blocks do not have to be

play04:05

loaded in as adjacent memory blocks they

play04:08

can be stored in any available page

play04:10

frame in the main memory now this is a

play04:13

more efficient scheme but it does come

play04:16

with complications we need a way to keep

play04:19

track of all the page locations which

play04:22

increases complexity in the operation

play04:24

through the use of three tables stored

play04:27

in the part of the main memory we can

play04:30

keep an eye and locations of various

play04:33

jobs the job table is a dynamic list

play04:36

that contains two values

play04:38

the size of the job and the page map

play04:41

table location of that job the page map

play04:44

table contains important information for

play04:46

each of the pages the page number and

play04:49

its corresponding page frame memory

play04:52

address

play04:52

finally the memory map table has one

play04:56

entry for each page frame listing both

play04:59

its location and a status informing

play05:02

whether it is in a busy or free State

play05:04

now that we have an understanding of

play05:07

paged map allocation we can now see how

play05:10

demand paging works it's very similar to

play05:14

the previous concept but the main

play05:16

difference is that pages are loaded on

play05:18

demand meaning that pages are only

play05:21

brought into memory when they are

play05:23

actually needed the page map table we

play05:26

looked at before increases with three

play05:29

more columns one to determine if the

play05:32

page is already in memory known as the

play05:34

status the second to check if the page

play05:37

has been modified and a third to check

play05:40

if the page has been referenced recently

play05:42

how do we determine replacement of pages

play05:46

by using a page replacement policy

play05:49

first-in first-out least recently used

play05:52

least frequently used and most recently

play05:56

used our replacement policies used to

play05:59

change pages based on a specific

play06:00

algorithm these are all pretty

play06:03

self-explanatory and are crucial to the

play06:06

efficiency of the system so we have

play06:09

looked at page map allocation and demand

play06:12

paging but what else is there well we

play06:16

have looked at separating the jobs into

play06:18

pages what if we could break it down

play06:20

even further we can segmented memory

play06:24

allocation splits the job into separate

play06:27

segments that reflect the nature and

play06:29

structure of the code usually

play06:32

when you view a script it is separated

play06:34

into individual functions or subroutines

play06:37

that can be called one at a time you may

play06:40

have a function called add then makes a

play06:43

calculation of two numbers and a

play06:45

function called

play06:46

divide we can call these one after the

play06:50

other and they will run in the chose

play06:52

in order now take all of these functions

play06:55

and label them as segments instead of

play06:58

using a page map table

play07:00

we now have a segment map table that

play07:03

makes a list of all of the varied sized

play07:06

segments that need to be put in the main

play07:08

memory to process now we move on to the

play07:12

final scheme it is a mixture of

play07:14

segmented and demand paging memory

play07:17

allocation it offers the logical

play07:20

benefits of the segmentation idea as

play07:23

well as the physical benefits of paging

play07:25

there is no new logic involved but there

play07:29

are some minor modifications to point

play07:31

out it makes use of both the segment map

play07:35

table and page map table plus additional

play07:38

information of authority to read write

play07:41

and execute a file a major disadvantage

play07:45

of this is the overheads and complexity

play07:48

of adding in more tables to handle the

play07:50

load

play07:51

why is virtual memory a good thing well

play07:55

let's say we currently have RAM that is

play07:58

fully occupied and has no time for jobs

play08:01

waiting to be slotted into it because we

play08:03

use segmentation and paging we can

play08:06

exceed memory capacity by turning to the

play08:09

backup memory the hard drive and

play08:12

although it's a slower alternative it

play08:15

can act as an extension to the RAM we

play08:18

have come a long way in memory but at an

play08:22

increased processing cost the operating

play08:24

system can provide a more efficient

play08:27

service to allow the CPU the central

play08:30

processing unit to handle jobs with

play08:33

better timeframes and effectiveness this

play08:36

has been Shawn and in the next episode

play08:39

we will move on to the process manager

play08:41

please

play08:42

do not forget to subscribe to the S MKS

play08:45

Channel

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Memory ManagementOperating SystemsContiguous MemoryFixed PartitionsDynamic PartitionsPaged AllocationDemand PagingSegmented MemoryVirtual MemoryEfficiencyPerformance