Miscellaneous in OS

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.[1] 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.

https://en.wikipedia.org/wiki/Static_library

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.

https://en.wikipedia.org/wiki/Dynamic_linker

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.

Advantages:-

->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:

  • Swapping
  • Paging
  • Segmentation

https://www.tutorialspoint.com/operating_system/os_memory_management.htm

https://www.youtube.com/watch?v=xAvC-MJ_Sz8

Fragmentation:

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

Page Fault:

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:

more at…….https://www.tutorialspoint.com/operating_system/os_virtual_memory.htm

 

 

 

Logical Address in OS

Logical Address:

  • Logical address is generated by the CPU.
  • If you are intended to run a program it has to be available in the location that is provided by the  Logical address .
  • All Applications runs based on the logical address only.They don’t interact with physical addresses directly.
  • It is a reference which is having access to physical memory.
  • The set of references(more than one) which are used by an application is called “LOGICAL ADDRESS SPACE“.
  • A logical address has to map with physical memory in order to run an application.
  • The set of all physical addresses that are mapped to the logical address is called “PHYSICAL ADDRESS SPACE“.
  • MEMORY MANAGEMENT UNIT is responsible for mapping the logical addresses to the physical address.It has many strategies to map the logical address to physical address like(Adding the relocation number to the logical address) etc.
  • Mapping can be done in 3 ways (COMPILE TIME(memory locations are known in advance and PA LA are going to be same),LOAD TIME(memory locations are not known and PA LA are going to be same) And EXECUTION TIME(Needs H/w involvement and PA LA Are going to be different).

 

WHY LOGICAL MEMORY IS IMPORTANT…?:

  • With out logical  memory if i want run a program i need push the entire process to disk .This is going to be tedious in the case of large processes.
  • I can’t use the memory which got allocated for another process  by another process.
  • Slack time(The time for navigation in disk drive) would become higher.
  • Read/Write operations on physically leads to information loss or corruption.

 

Links: