L-5.18: Overlay | Memory Management | Operating system

Gate Smashers
6 Apr 201811:11

Summary

TLDRThe video script delves into the concept of overlay, a technique used to manage large processes in limited main memory by dividing them into smaller, manageable partitions. It explains the process of dividing and loading only the necessary functionality at a time, which is particularly useful in embedded systems with fixed functionalities and limited memory. The script also discusses the challenges of manual partition division and the lack of an operating system driver to support overlays. It contrasts overlay with virtual memory, a more common approach in PCs, and provides an example calculation for determining the minimum partition size required for a two-pass assembler.

Takeaways

  • 📚 Overlay is a technique used to load large processes into a main memory smaller than the process size by dividing the process into smaller, manageable parts.
  • 🔍 The concept of fixed partitioning has a constraint where the maximum process size cannot exceed the largest partition size in the main memory.
  • 🔄 Overlay allows for the dynamic loading and unloading of process segments into the main memory based on the functionality needed at a given time.
  • 🛠️ In overlay systems, there is no operating system support for managing the process segments, so users must manually divide the process appropriately.
  • 🔧 The division of a process in an overlay system should be independent to avoid dependencies between segments that could lead to errors during execution.
  • 📱 Overlay is commonly used in embedded systems where functionality is fixed and predictable, allowing for easier manual division of processes.
  • 🏗️ In embedded systems, the limited main memory size necessitates the use of overlay to bring in one functionality at a time as needed.
  • 💡 The concept of overlay is not typically used in modern PCs and desktops, where virtual memory and demand paging are preferred for managing memory.
  • 🔢 The minimum partition size required for an overlay system can be calculated by considering the largest memory requirement when loading a single pass of a process along with other necessary components.
  • 🔧 In the example of a two-pass assembler, the partition size should be large enough to accommodate the pass with the highest memory requirement, which includes the assembler pass, symbol table, common routine, and overlay driver.
  • 📈 The overlay technique is particularly useful in situations where the main memory is limited and processes are larger than the available memory space.

Q & A

  • What is the concept of overlay in memory management?

    -Overlay is a memory management technique used to accommodate large processes that exceed the size of the main memory. It involves dividing the process into smaller segments or partitions and loading only the necessary segment into the main memory at a time.

  • How does the overlay technique work when the process size is more than the main memory size?

    -In the overlay technique, the process is divided into smaller parts, and only the part that is needed at the moment is loaded into the main memory. Once the task of the loaded part is completed, it is swapped out, and another part is loaded in its place.

  • What is the constraint of fixed partitioning in memory management?

    -Fixed partitioning limits the size of the process that can be loaded into the main memory to the size of the largest partition. If a process is larger than the largest partition, it cannot be loaded entirely into the main memory.

  • Why is the overlay technique commonly used in embedded systems?

    -The overlay technique is commonly used in embedded systems because these systems typically have fixed functionalities and limited main memory. Users can manually divide the process into independent, functional segments that can be loaded sequentially as needed.

  • What is the problem with the overlay technique when it comes to process division?

    -The problem with the overlay technique is that it requires the user to manually divide the process into independent segments. If the segments are not independent, it can lead to issues where the CPU cannot find the necessary data or code to continue execution.

  • Why is the overlay technique not commonly used in modern PCs?

    -Modern PCs do not commonly use the overlay technique because they rely on virtual memory and demand paging, which allows for more efficient use of the main memory by swapping in and out pages as needed, rather than requiring manual segmentation of processes.

  • What is a two-pass assembler and how does it relate to the overlay concept?

    -A two-pass assembler is a type of assembler that requires two passes over the source code to generate the object code. It relates to the overlay concept because each pass can be considered a separate segment that can be loaded into memory as needed, demonstrating the overlay technique in practice.

  • What is the minimum partition size required for a two-pass assembler with an overlay driver of 10kb size?

    -The minimum partition size required is 150kb, which is the size needed to load pass 2 along with the symbol table, common routine, and overlay driver, as this is the larger of the two scenarios when only one pass is in use at a time.

  • How does the overlay technique handle the symbol table and common routine in a two-pass assembler scenario?

    -In the overlay technique for a two-pass assembler, the symbol table and common routine are loaded along with the active pass. When one pass is completed and swapped out, the other pass, along with the necessary components, is loaded into the main memory.

  • What is the significance of the overlay driver in the context of the two-pass assembler example?

    -The overlay driver is a component that facilitates the loading and unloading of different segments in the overlay technique. In the context of the two-pass assembler, it is necessary for managing the memory when switching between the two passes.

  • Why is the maximum partition size chosen for the overlay technique in the two-pass assembler scenario?

    -The maximum partition size is chosen to ensure that the largest segment, which in this case is pass 2 with its associated components, can fit into the main memory. This prevents the issue of not being able to load a necessary segment because the memory is too small.

Outlines

00:00

💡 Understanding Overlay in Memory Management

This paragraph introduces the concept of overlay, a technique used to accommodate large processes in main memory that exceed its size. It explains how processes can be divided into partitions and loaded into memory as needed, overcoming the limitations of fixed partitioning. The discussion highlights the challenges of manually dividing processes and the suitability of overlays for embedded systems, where functionality is fixed and predictable. The paragraph also touches on the limitations of overlays in general-purpose computers, where processes vary in size and number, and the concept of virtual memory is more appropriate.

05:03

🔍 Calculating Partition Sizes for Overlays

The second paragraph delves into a practical example of using overlays, specifically in a two-pass assembler scenario. It outlines the process of calculating the minimum partition size required when the main memory is less than the total size of the assembler. The example includes the sizes of pass 1, pass 2, the symbol table, common routine, and overlay driver. The paragraph explains how to determine the maximum partition size needed to accommodate both passes and their associated components, emphasizing the importance of choosing the larger of the two partition sizes to ensure efficient memory usage.

10:08

📚 Overlays vs. Virtual Memory in Real-Time Systems

The final paragraph summarizes the use of overlays, emphasizing their application in systems with limited main memory, such as embedded systems. It contrasts the overlay technique with virtual memory, which is more commonly used in PCs and involves swapping pages in and out of memory. The paragraph concludes by reinforcing the concept that overlays are primarily used when the main memory is insufficient to hold the entire process, and virtual memory techniques are employed in systems where memory is more abundant and processes are more dynamic.

Mindmap

Keywords

💡Overlay

Overlay is a method used to manage processes larger than the main memory by dividing the process into smaller sections and loading them as needed. This allows a process to run even if its size exceeds the available memory, which is particularly useful in embedded systems with limited memory. The video explains how overlay helps accommodate larger processes by loading and unloading sections based on their usage.

💡Main memory

Main memory, also known as RAM, is the primary storage area where processes are loaded for execution. The video highlights the limitation of main memory size and how it necessitates the use of techniques like overlay to handle processes larger than the available memory. Main memory size constraints are a key factor in determining the need for overlay.

💡Partition

A partition is a fixed-size section of the main memory allocated to processes. The video discusses fixed partitioning and how it limits the maximum process size that can be loaded. By using overlay, processes can be divided to fit within these partitions, allowing larger processes to run by swapping sections in and out.

💡Embedded system

Embedded systems are specialized computing systems that perform dedicated functions, often with limited memory and processing power. The video mentions that overlay is commonly used in embedded systems because users can manually divide processes based on the system's fixed functionality, making efficient use of limited memory.

💡Symbol table

A symbol table is a data structure used in compilers and assemblers to store information about variables, functions, and other entities. The video includes a problem where the symbol table size is considered in the memory calculations for an assembler using overlay, emphasizing its role in process execution.

💡Common routine

Common routine refers to code sections that are frequently used by different parts of a program. The video discusses how common routines need to be loaded into memory along with the process partitions, impacting the total memory requirement. They are essential for efficient process execution and are factored into overlay calculations.

💡Assembler

An assembler is a tool that converts source code written in assembly language into object code. The video uses the example of a two-pass assembler to illustrate the concept of overlay, showing how different passes of the assembler are loaded and unloaded from memory to manage limited memory resources.

💡Two-pass assembler

A two-pass assembler processes the source code in two stages: the first pass gathers information and the second pass generates object code. The video demonstrates how overlay can manage the memory requirements of each pass by loading only the necessary pass into memory along with other required components like the symbol table and common routines.

💡Virtual memory

Virtual memory is a memory management technique that allows the execution of processes that may not be completely in the main memory. The video contrasts overlay with virtual memory, noting that virtual memory is used in modern PCs to handle larger processes through demand paging, whereas overlay is more suited for embedded systems.

💡Demand paging

Demand paging is a technique where pages of a process are loaded into memory only when they are needed, reducing the memory footprint. The video mentions demand paging as part of the virtual memory concept, explaining that it allows more efficient use of memory compared to overlay by dynamically loading and unloading pages based on demand.

Highlights

Overlay allows large processes to be accommodated in main memory by dividing them into smaller parts.

In fixed partitioning, the maximum process size is limited by the largest partition, which is a constraint.

Overlay is used when the main memory is smaller than the process size, requiring the process to be divided and loaded in parts.

The process is divided into partitions based on the functionality needed first, which is then loaded into main memory.

There is no built-in driver in the operating system for overlay, requiring users to manually decide how to divide the process.

The concept of overlay is particularly useful in embedded systems where functionality is fixed and predictable.

In embedded systems, the process can be divided into functions that are executed sequentially, fitting the limited main memory.

Division of the process in overlay must be independent to avoid dependencies between partitions, which could lead to errors.

Overlay is less suitable for PCs and desktops where processes vary in size and number, making manual division impractical.

Virtual memory is used in PCs instead of overlay, involving swap-in and swap-out of pages.

A two-pass assembler example is used to illustrate the concept of overlay, where only one pass is in use at a time.

The minimum partition size required for the assembler example is calculated based on the size of the passes, symbol table, common routine, and overlay driver.

The partition size must be the maximum of the two scenarios (pass 1 or pass 2 loaded) to ensure all necessary components fit in memory.

The concept of overlay is primarily used in embedded systems due to their fixed functionality and limited main memory.

In real-time systems like PCs, virtual memory is preferred over overlay for managing memory with larger and varying process sizes.

The calculation of partition size in overlay involves adding the sizes of all components needed for a single pass of the process.

The overlay technique is less common in modern systems, being replaced by virtual memory and demand paging.

Transcripts

play00:00

- Overlay- Overlay is a method by which a large size process can be put into the main memory, means

play00:07

- if the size of my process is more than the size of memory, then I can make that process accommodate in the main memory by using the concept of overlay

play00:18

- How? Let say, I've 4 partitions in main memory, 2mb, 4mb, 8mb and 16mb

play00:25

- Now, what is the size of maximum partition, 16mb, here what constraint comes in fixed partitioning

play00:33

- that I cannot make process bigger than 16mb enter. But if we use overlay

play00:40

- then I can accommodate the process even more than 16mb. So where do we use overlay?

play00:49

- Where the size of our main memory is less than the size of process. So in that case we bring that process in main memory

play00:58

- and how we allocate memory to it, this is a point. Now how does overlay use this

play01:05

- when we, the process whose size is more than main memory, we cannot bring in all that directly because obviously main memory size is smaller and process size is bigger

play01:16

- so in process, what we'll have to do, we'll have to divide the process, what it meant to say, that we will divide the process/program/object code

play01:27

- and the code/functionality that is needed first we will load the functionality in main memory.

play01:35

- when the work of that functionality will be done then we will bring it out and bring in another partition, and third after the second, we have to bring in the partitions like this

play01:47

- so overlay is creating a problem here that there is no driver in the operating system which support the overlay

play01:57

- means, here user have to decide on it's own how to divide that process/program so that whenever I bring in the partition

play02:07

- I could execute it's functionality properly. Then bring it out and then bring in another program

play02:13

- so like this, there can be a very big problem, it may happen that the work I have to do first, I didn't bring in that partition first - so actually this concept of overlay is used in embedded system because in embedded

play02:23

- because user is dividing here. Now user divides manually on it's end, it can divide however it wants

play02:35

- embedded system are those where my functionality is fixed, means those circuits that perform only fixed type of functionality

play02:43

- like my washing machine, in that I know it only works on a fixed functionality.

play02:50

- so what can I do there, I can divide that process and creat 2-3 different functions

play02:58

- and main memory, obviously my main memory is limited in embedded system. So I'll bring in one functionality

play03:05

- when it's work will be completed, I'll bring in second functionality, when it's work will be completed, I'll bring it out and I'll bring in third

play03:13

- but the problem here is, that when the user will divide those functionality/process

play03:21

- then that division should be independent. Independent means if I bring in this partition.

play03:28

- So it should not be like some codes in this partition is depending upon that partition. Otherwise a problem can be created there that the data CPU is searching, it can't find that

play03:42

- but this doesn't create a problem in embedded system because the function/process in embedded system is fixed

play03:50

- but in computers, the PCs, desktops, there our processes are of different size, there are different no. of process

play03:59

- so there I cannot leave the functionality here on user that it divides itself , how should we divide that, how we should create it

play04:09

- so that's why this concept of overlay is used in embedded system. It is still used in many embedded systems.

play04:16

- but we don't use this in our computers, here we use the concept of virtual memory.

play04:22

- we will discuss the concept of virtual memory or demand paging in further videos. So let's discuss a question about how we actually use overlay

play04:33

- like we have, consider a two pass assembler, pass 1 80 kb, pass 2 90 kb

play04:39

- symbol table is of 30kb, common routine 20kb, at a time only one pass is in use. What is the min. partition size required if the overlay driver is of 10kb size

play04:52

- means, here they are talking about, that I have a assembler here, why do we use assembler?

play04:58

- Assembler is used to convert source code into object code

play05:03

- and for that here I'm using 2 pass assembler, means it's working in 2 passes

play05:09

- when we'll use pass 1 then there is no need of using pass 2 and when we'll use pass 2 then there is no need of using pass 1

play05:19

- So if I look at the total size here, then size of pass 1 is 80kb, size of pass 2 is 90kb

play05:29

- Symbol table, which is mandatory, 30kb. Common routine 20kb and how we have to bring in pass 1 in main memory

play05:40

- and then bring it out and then again bring in pass 2 and bring it out from main memory, for that here is a overlay driver

play05:48

- and the size of that driver is 10kb

play05:51

- 10 kb

play05:52

- So what's the total here

play05:57

- it's, 200.., 220.., 230

play06:00

- 230 kb

play06:03

- means the all here, the size of the whole program became 230 kb. Means, if the size of my memory is 230 kb.

play06:12

- Then, there's no problem, you can directly work with this full function/process because your memory size is 230 kb

play06:21

- but, that's where we are using the concept of overlay. Let say, the size of my memory is not 230kb, it is less than 230kb.

play06:31

- So when the size is less than 230kb, then I cannot keep the whole process/assembler in the main memory at a same time because we're assuming main memory size is less than 230kb

play06:46

- So here it is asked in question that, the partition or how much should be the size of main memory so that I can use overlay there and use the passes properly

play06:56

- so it's already mentioned in the question that at a time only 1 pass is in use. Means, if we use pass 1, it's size is 80kb

play07:08

- if we load pass 1 first so that means we have a requirement of 80kb plus 30kb symbol table

play07:17

- 20kb for common routine and 10kb for overlay driver

play07:25

- that means, what the total is?

play07:29

- 140

play07:31

- 140 kb

play07:34

- Means if I load pass 1 first, along with the symbol table, common routine. Then I need 140 kb of memory here.

play07:43

- So can I take 140 kb of memory, will this 140 kb memory be enough for my work? Wait,

play07:50

- We haven't calculated pass 2 yet. If we bring out

play08:00

- pass 1 from main memory after loading it and then load pass 2,

play08:06

- then the size of pass 2 is 90kb

play08:09

- and when we'll load pass 2, symbol table is also needed, common routine is also needed and drive is also needed.

play08:17

- so here my total is, 150 kb

play08:22

- 150kb. If I load pass 1, 140kb and if I load pass 2, 150kb

play08:28

- means if I keep size of one partition in the memory

play08:35

- 150kb

play08:37

- Then, when that size will be of 150kb, means, there's a empty space of 150kb

play08:44

- when I'll load pass 2, then my full 150kb will be filled

play08:50

- pass 1 isn't needed at that time because when we load pass 2, at a time only 1 pass is used, means, only 1 pass is in use.

play08:58

- then I'll load pass 2 at that time. And when pass 2 will get out of here then I'll load pass 1

play09:04

- when pass 1 will come in, it's occupying the memory 140kb. So 140kb can easily be accommodated in 150kb.

play09:13

- so that's the point here that you have to choose the one which is max. out of these two. Means, if we're using pass 1, our total requirement is of 140kb

play09:25

- and if we load pass 2, our total requirement is of 150kb

play09:30

- so if I keep a partition of 140kb, then the problem still exists. The partition is of 140kb, when the pass 2 of 150kb will come

play09:42

- then how will you fit that? 150kb won't fit in 140kb. So the best thing is that choose the partition of size which is larger or which has maximum no.

play09:52

- So that means, the answer of this question can be 150kb

play09:58

- So this was about partition. Even if you're asked normally that what should be size of main memory? If the size of my main memory is 230 kb

play10:08

- then there is no need of using overlay. We use overlay where the main memory is limited and processes are quite larger.

play10:18

- we use overlay in that case. So that's why, if you're asked this type of question, then simply calculate it first, and out of those values the one with maximum value is the size of partition

play10:31

- or we can say that will be the size of main memory. It can be asked in any of these terms, it maybe possible they ask in terms of partition or they may ask in terms of main memory requirement, so you can calculate that

play10:43

- so that's why we use the concept of overlay where my main memory is limited

play10:49

- and most of time this happens in embedded system. In real time, we don't use this in our PCs. In real time, we use the concept of virtual memory, where is swap-in and swap-out the pages.

play11:01

- how we do demand paging or how we use that, that we will see in the further videos.

play11:07

- This is all about the concept of overlay. Thank you.

Rate This

5.0 / 5 (0 votes)

Related Tags
Memory ManagementOverlay TechniqueEmbedded SystemsMain MemoryProcess SizingVirtual MemoryPartitioningTwo-Pass AssemblerMemory AllocationDemand Paging