Static vs Dynamic loading of memory:
Static: If we want a program to be loaded at compile time,You have to be get ready with the all the dependency files of main program by compile time only.The linker will links all files to the memory.
In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-aloneexecutable. This executable and the process of compiling it are both known as a static build of the program. Historically, libraries could only be static. Static libraries are either merged with other static libraries and object files during building/linking to form a single executable, or they may be loaded at run-time into the address space of the loaded executable at a static memory offset determined at compile-time/link-time.
Dynamic: If we want a program to be loaded at run time,Your compiler will compile all the dependency files of main program by run time.The DLL will links all files to the memory.
In computing, a dynamic linker is the part of an operating system that loads and links the shared libraries needed by an executable when it is executed (at “run time“), by copying the content of libraries from persistent storage to RAM, and filling jump tables and relocating pointers. The specific operating system and executable format determine how the dynamic linker functions and how it is implemented.
Linking is often referred to as a process that is performed when the executable is compiled, while a dynamic linker is a special part of an operating system that loads external shared libraries into a running process and then binds those shared libraries dynamically to the running process. This approach is also called dynamic linking or late linking.
1) What is static loading in programming language?
Static loading:-A piece of code can be loaded into RAM(Random access memory)before it is executed means after being loaded into the RAM it may or may not be get executed.
Drawbacks in static loading
->wastage of memory during the program execution because allocation of memory occupied by the static loaded program so it releases when the execution is completed
->C is one of the static loading programming languages.
->static loading happened in structural programming language.
2) 2) What is dynamic loading in programming language?
Dynamic loading:-A piece of code can be loaded into RAM (Random access memory) when it is necessary to be executed.
->Object oriented programming languages follows dynamic loading methodology. Examples: – java,.net,c++ and etc
è It uses less time to execute the programs.
->even though we have less memory the program definitely executed.
Memory Management types:
Internal(The size is too big than needed)
Extrenal(The size is too small than neede)
Why Paging is needed:
OS performs an operation for storing and retrieving data from secondary storage devices for use in main memory. Paging is one of such memory management scheme. Data is retrieved from storage media by OS, in the same sized blocks called as pages. Paging allows the physical address space of the process to be non contiguous. The whole program had to fit into storage contiguously.
Paging is to deal with external fragmentation problem. This is to allow the logical address space of a process to be noncontiguous, which makes the process to be allocated physical memory
A page fault occurs when a program accesses a page that has been mapped in address space, but has not been loaded in the physical memory.
Page fault algorithms:
- Optimal Page Replacement Used(https://www.youtube.com/watch?v=uV9Idh2dgBY).
- Least Recently Used(https://www.youtube.com/watch?v=EX_T8yLhoio)