Memory management under Windows The Need for Memory:-  The window environment and most applications that run under it need access to phenomenal amounts.

Slides:



Advertisements
Similar presentations
Lectures on File Management
Advertisements

Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
The Linux Kernel: Memory Management
An Overview of Palm OS n Designed for special hardware –small screen ( 160 x 160 ) –less processing power than desktop PCs –quick turnaround expected –limited.
Fixed/Variable Partitioning
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
CPSC 388 – Compiler Design and Construction
CS 311 – Lecture 21 Outline Memory management in UNIX
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Computer Organization and Architecture
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Operating Systems.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Memory Allocation CS Introduction to Operating Systems.
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao ISBN: CMPBooks.
Operating Systems.  Operating System Support Operating System Support  OS As User/Computer Interface OS As User/Computer Interface  OS As Resource.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Operating Systems Chapter 8
Operating system Structure and Operation by Dr. Amin Danial Asham.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
CY2003 Computer Systems Lecture 09 Memory Management.
1 Memory Management Requirements of memory management system to provide the memory space to enable several processes to execute concurrently to provide.
Games Development 2 Concurrent Programming CO3301 Week 9.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
Computer Systems Week 14: Memory Management Amanda Oddie.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
Lecture 7 Page 1 CS 111 Summer 2013 Dynamic Domain Allocation A concept covered in a previous lecture We’ll just review it here Domains are regions of.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
I/O Software CS 537 – Introduction to Operating Systems.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Computer Architecture Chapter (8): Operating System Support
Memory Management.
Non Contiguous Memory Allocation
Processes and threads.
Process Management Process Concept Why only the global variables?
Memory Allocation The main memory must accommodate both:
Advanced OS Concepts (For OCR)
William Stallings Computer Organization and Architecture
CSI 400/500 Operating Systems Spring 2009
ECE 391 Exam 2 HKN Review Session
Main Memory Management
Chapter 8: Main Memory.
Economics, Administration & Information system
Optimizing Malloc and Free
Main Memory Background Swapping Contiguous Allocation Paging
Operating Systems.
Memory Management Tasks
Lecture 3: Main Memory.
Threads Chapter 4.
The Main Features of Operating Systems
Chapter 2: Operating-System Structures
COMP755 Advanced Operating Systems
Presentation transcript:

Memory management under Windows The Need for Memory:-  The window environment and most applications that run under it need access to phenomenal amounts of memory.  Multitasking is part of the reason: system must have ability to load and execute several large applications simultaneously.  The GUI too calls for increased amounts of memory.  Bitmaps, icons, cursors: they all need much larger amount of memory then the simple screen elements of text-based systems.

 The operating system itself primarily exists as a collection of dynamic-link libraries, which must be loaded into memory to provide support to executing applications, as must the various device drivers which allow access to hardware as essential as the video card, the mouse, and the keyboard.  It is imperative for windows to access and efficiently manage huge amount of memory if everything is to work together as a speedy and usable environment.

Memory Handles and Locks The most computers running Windows do have large amounts of memory physically installed on them, windows memory management must seem like a pretty straightforward chore. In fact, things are pretty simple when the system starts up. A single huge amount of memory, almost limitless in size, is available. All that’s needed is a system that curves out small chunks from this as and when required, and parcels them out as users load up more applications. As soon as an applications terminates, all the memory earmarked launched by the user. This seems good enough on paper, but things turns out very differently in practice. As a programs allocates and discard memory blocks of various size, a stage arrives where most of the memory available in the system gets broken up into tiny piece of intermingled free and allocated memory blocks.

As a result of this, the system fails to load fresh applications because, even though enough memory is available, no single block of memory is large enough to accommodate the new application’s code. In fact, the system behave exactly as if it had run out of memory, and the presence of large amounts of physical memory doesn’t achieve much. This “fragmentation” of memory under multitasking system is a well-known phenomenon, and the consolidation of widely Scattered chunks of free memory is central to the windows memory management scheme.

Solution for the fragmentation problem It must be clear that memory movement holds the key to the memory fragmentation problem. The operating system must devise some through which it can be safely coalesce several smaller free blocks together into a single large one by moving out the intervening could cause severe problems. A program would be allocate memory, and the system would move it away to a different location later, effectively pulling the rug from under the application program’s feet.

Solution:-Concept of Locking Window uses the concept of memory handles as a solution. Whenever programs request memory, a memory block is allocated, and a memory handle is returned to the program instead of the block’s address. Whenever applications programs need to access to access the memory block, they can “lock” the block using a special window API function. Window make sure that the specified block was not moved during the compaction process, and also return the block’s current physical address for the program’s use.

After finishing its processing tasks, the program can use another API function to “unlock” the memory block, once again allowing windows to move this block whenever required. Problem Persist:- Though locking did provide an answer to the fragmentation problem. Many problem still remained. Application program could not leave memory blocks locked in place for a long time, because even a single unmovable block would be enough to negate windows’ memory compaction efforts. In fact, programmers had to continuously on their toes to unlock every memory block as quickly as possible.

The effect of premature unlocking had its own perils: Windows would move the block, while the program would continue accessing it using the old address, the program would most likely crash. A special testing programs called “shakers” were used to detect these bugs. These worked by forcing windows to move memory blocks around, in an attempt to expose smoke out any hidden glitches.

The Memory API Windows provides a large set of memory management functions, which provides a fairly low level of control over how memory management and protected mode selector management:- 1.GlobalLRUNewest():- marks a global memory block as the most recently used block, making it the least favored block for discarding by windows. 2.GetSelectorBase():- looks up the 80x86 descriptor table and retrieves the base physical address associated with a particular selector.

List of functions:-used for allocating and managing global memory blocks 1.GlobalAlloc() 2.GlobalFree() 3.GlobalReAlloc() 4.GlobalLock()

1.The GlobalAlloc() function is used for allocating a memory block of any desired size. We pass two parameters: allocations flags and allocations size. Allocations flags control how windows satisfies the allocations request. Syntex :- GlobalAlloc(UINT fAlloc, DWORD cbAlloc) The cbAlloc parameter contains the requested memory size. The maximum allowed values depend on the microprocessor that’s being used: mb- 80 bytes mb- 64 kb

The GlobalAlloc() function returns a handle to the allocated memory block, which has the data type HGLOBAL. 2. GlobalFree() performs the reverse actions, by freeing the given memory block after we have finished using it. The memory block must not be locked when GlobalFree() is called. Syntax:- HGLOBAL GlobalFree(HGLOBAL hglb) We pass single parameterha, the global memory handle which is to be freed. 3. GlobalReAlloc():- it can be used to change the block’s size even after the block has been allocated and loaded up with data. It can also be used to change the block’s allocations flags at any time.

Syntax :- HGLOBAL GlobalReAlloc(HGLOBAL hglb, DWORD cbAlloc, UINT fAlloc) Three parameter are required: memory handle, new allocation size, and allocation flags. 4. The GlobalLock():- functions locks up the given block, preventing windows from moving and discarding it, and also return a FAR pointer containing the physical address. It is possible to lock the same block more than once, because window maintains a “lock count” for each block. Syntax:- Void FAR *GlobalLock(HGLOBAL hglb)

The Kernel Macros We can lock all our memory blocks, so we should eliminate all the monotony of repeated sequences. Windows provides a set of three very useful macros for this purpose:-  Void FAR *GlobalAllocptr( UINT fAlloc, DWORD cbAlloc)  Bool GlobalFreeptr(Void FAR *lp)  Void Far *GlobalReAllocptr(void FAR *lp, DWORD cbAlloc, UINT fAllocate)

These memory allow us to work directly with far memory pointers, making it unneccessary for us to even save the windows memory blocks.