1 / 17

Operating Systems, by Dhananjay Dhamdhere

Static and Dynamic Memory Allocation. Memory allocation is an aspect of a more general action in software operation known as binding Static allocation performed by compiler, linker, or loader Sizes of data structures must be known a priori Dynamic allocation provides flexibility

sheryl
Download Presentation

Operating Systems, by Dhananjay Dhamdhere

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Static and Dynamic Memory Allocation Memory allocation is an aspect of a more general action in software operation known as binding Static allocation performed by compiler, linker, or loader • Sizes of data structures must be known a priori Dynamic allocation provides flexibility • Memory allocation actions constitute an overhead during operation Operating Systems, by Dhananjay Dhamdhere 1

  2. LINKERS

  3. Execution of Programs A has to be transformed before it can be executed Many of these transformations perform memory bindings • Accordingly, an address is called compiled address, linked address, etc Operating Systems, by Dhananjay Dhamdhere 3

  4. Why Linkers ?? • Modularity • Program can be written as a collection of smaller source files, rather than one monolithic mass. • Can build libraries of common functions • e.g., Math library, standard C library • Efficiency • Time: • Change one source file, compile, and then relink. • No need to recompile other source files. • Space: • Libraries of common functions can be aggregated into a single file... • Yet executable files and running memory images contain only code for the functions they actually use.

  5. Introduction to Linkers • Linking • The process of collecting and combining various pieces of code and data into a single file that can be loaded (copied) into memory and executed. • Linking time • Can be done at compile time, i.e. when the source code is translated • Or, at load time, i.e. when the program is loaded into memory • Or, even at run time. • Static Linker • Performs the linking at compile time. • Takes a collection of relocatable object files and command line arguments and generate a fully linked executable object file that can be loaded and run. • Performs two main tasks • Symbol resolution: associate each symbol reference with exactly one symbol definition • Relocation: relocate code and data sections and modify symbol references to the relocated memory locations • Dynamic Linker • Performs the linking at load time or at run time.

  6. relocation_factorP = l_originP – t_originP lsymb = tsymb + relocation_factorP Performing Relocation re Ref : 224 – D M Dhamdhere

  7. Relocation Instructions using memory addresses are address-sensitive Relocation is needed if program is to execute correctly in some other memory area: involves changing addresses Operating Systems, by Dhananjay Dhamdhere 7 Ref : 223 –Figure : 7.2 D M Dhamdhere

  8. Example - I I M P Ref : Pg: 226 Example 7.5 – D M Dhamdhere

  9. Solution - I Size A = 51 B = 69 C = 54 Load time Origin A = 300 B = 351 C = 420 Relocation Factor RFA = 300 – 200 = 100 RFB = 351 – 302 = 49 RFC = 420 – 480 = -60

  10. Design of Linker Relocation Requirement Linking Requirement Name Table (NTAB) – with the field of Synbols name and Linked_address eg. : Pg: 231 – Example : 7.9

  11. Self Relocating Programs Which program can be modified, or can modfied it self , to execute from a given Load Origin. Classifications : 1) Non Relocatable Program 2) Relocatable Programs 3) Self Relocating Programs Ref : pg: 232 7.3 Dhamdhere I M P

  12. Non Relocatable Program 1) Can't Execute in Any Memory Area, Only on Traslated Origin 2) Lack of Address Sensitive Instructions 3) e.g. Hand Coded Machine Language Program

  13. Relocatable Programs 1) Can Execute in Any Desired Memory Area 2) Availability of Address Sensitve Instruction 3) e.g. Object Module

  14. Self Relocating Programs 1) Can Execute in Any Memory Area 2) Availability of Own Address Sensitve Instruction 3) Relocating Logic Specified on the start of the Program 4) Useful for Time sharing Operating System

  15. Linking for Overlays Overlay : It is a part of a program that use same load origin as some part of the program. Advantages : ► Keep in memory only those instructions and data that are needed at any given time. ► Needed when process is larger than amount of memory allocated to it. ► Implemented by user, no special support needed from operating system, programming design of overlay structure is complex. ►Used to reduce the Main Memory Requirements. I M P

  16. An Overlay Tree

  17. Loader An operating system utility that copies programs from a storage device to main memory, where they can be executed. In addition to copying a program into main memory, the loader can also replace virtual addresses with physical addresses. Most loaders are transparent, i.e., you cannot directly execute them, but the operating system uses them when necessary. Absolute loader can only load origin = linked Origin.

More Related