The operating system of interview questions: the difference between dynamic link libraries and statically linked libraries

  Is a dynamic link library may be shared by other applications program modules, which encapsulate some routines and may be shared resources. Extension dynamic link library file name is generally dll, there may be drv, sys and fon, and it executable (exe) is very similar, except that although the dynamic link library contains the executable code can not perform alone, and applications should be called directly or indirectly.

  Dynamic link libraries are statically linked relative terms. The so-called static linking refers to the function or procedure to be invoked link to the executable file and become part of the executable file. In other words, the code functions and procedures in the program's executable file, the file contains all the code required to run time. When multiple programs call the same function, the memory will be multiple copies of this function, thus wasting valuable memory resources. And the function code is called dynamic link has not been copied into the executable file to the application, but only where the added function called description information (often some relocation information). Only starts running when the application is loaded into memory, the operating system under the management of relations before the establishment of the link between the application and the corresponding dynamic link library. When the called function is to be performed in a dynamic link library, according to the relocation information generated by the connection, the operating system before transferring to perform dynamic link library corresponding function codes.

  In general, if an application uses a dynamic link library, Win32 memory system to ensure that only a single copy of a dynamic link library, which is implemented by memory-mapped file. DLL is first transferred to the global stack Win32 system, and then mapped to call this dynamic-link library process address space. In the Win32 system, each process has its own 32-bit linear address space, if a dynamic link library is called multiple processes, each will receive a map of the dynamic link library.

Guess you like

Origin www.cnblogs.com/yichengming/p/11457223.html