[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To understand what happens when an extension is loaded, it necessary to first have an idea of how programs are built. Briefly, a programmer writes commands in a high-level programming language (like C, C++, Fortran, Java, etc--Cogsys is written in C) and saves these commands in a plain text file called the source file (or source code). Most programs are spread over many source files. Then, special tools are used to translate the source files into an actual executable program (like `COGSYS.EXE').
This translation happens in a two-step process. First, a compiler is used to translate each individual source file into a processor-specific object file. Object files can be collected together in libraries so different programs can easily share them. Then, a linker joins all the object files together with standard libraries (which are just collections of commonly used objects that are used by every program) to create the executable.
But the linker does more than just join the files. It also performs the important function of fixup. In any given source file `foo.c', the programmer can access things (like procedures or data) that he has defined in another source file (say, `bar.c'). Of course, at the time that `foo.c' is compiled, the compiler knows nothing about `bar.c' yet, specifically, it can't say exactly where the code of `bar.c' will be in the final file--only the linker will know that. So any reference in `foo.c' that refers to something outside of itself (say in `bar.c', or any other source file) must be left blank by the compiler. Fixup is the process of "filling in the blanks" that the linker does right after it has joined all the pieces.
The process described above is called static linking, which simply
means that all of the pieces of a program are put together before it is
used. Dynamic linking means that some of the object files are
loaded and fixed up after the program has started. These
dynamically loaded objects are usually collected into libraries, just
like static libraries described above. On Unix, these are
`libname.so' (shared object) files; on Windows, they are the
name.DLL
(dynamically linked library) files.
Dynamic linking follows the same sequence of events as static linking. First, the dynamic code is loaded into memory alongside the main program. Then, once the dynamic loader knows where it has positioned the newly loaded code, it must fixup references in the main code. Now the main code can call the dynamically loaded code.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |