At the user level it is possible to avoid of the fragmentation problem when

At the user level it is possible to avoid of the

This preview shows page 60 - 62 out of 102 pages.

At the user level, it is possible to avoid of the fragmentation problem when writing programs. For example, if a program allocates and frees memory objects of random sizes, it will be a random issue whether or not the holes left over can be used again. If, on the other hand, a program only allocates memory in fixed size structures (like C's struct and union variable types), then every hole will be the same size as every new object created and (as with pages) it will always be possible to fit new data into old holes. This is a program design consideration. Unions were designed for precisely this kind of purpose. 5.1.10 Reclaiming fragmented memory (Tetris!) There are two strategies for reclaiming fragmented memory. 1. Try to fit data into the holes that already exist. 2. Reorganize the data so that all the holes are regrouped into one large hole. The second alternative clearly represents a large system overhead and is seldom used. The first method can be implemented in one of three ways. Given a free-list of available holes, one may choose a space on the basis of First fit. Choose the first hole which will do. Best fit. Choose the smallest hole that will do. Worst fit Choose the largest hole (which in some screwy sense leaves the biggest remainder - for what it's worth). The first two are preferable, but neither works best in all cases. The criterea are i) minimization of fragmentation and ii) minimization of the allocation overhead. The first is perhaps preferable, since it is fastest.
Image of page 60
5.2 Virtual Memory 5.2.1 Paging and Swapping Virtual memory is a way of making the physical memory of a computer system effectively larger than it really is. Rather than using mirrors, the system does this by determining which parts of its memory are often sitting idle, and then makes a command decision to empty their contents onto a disk, thereby freeing up useful RAM. As we noted earlier, it is quite seldom that every byte of every program is in use all of the time. More often programs are large and contain sections of code which are visited rarely if ever at all by the majority of users - so if they are not used, why keep them in RAM? Virtual memory uses two methods to free up RAM when needed. Swapping. An entire process, including code segment and data segments is expunged from the system memory. Paging. Only single pages are swapped out. Of course, the simplest way to clear a space in RAM is to terminate some processes, but virtual memory is more subtle than that. The idea is to free RAM only temporarily, with the intention of copying the data back again later. All of this should happen in such a way that the user of the system do not realize that it is happening. Swapping and paging dump the system memory in special disk caches. Normally these disk areas are not part of the usual file system structure, since the overhead of maintaining a file system is inapropriate when only the system needs to use the disk. Instead, the system stores swap files in large contiguous blocks, sacrificing utilization of space for speed. Some systems also allow swapping to a special file in the normal
Image of page 61
Image of page 62

You've reached the end of your free preview.

Want to read all 102 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors