Professional Documents
Culture Documents
Co PPT
Co PPT
ORGANIZATION
OVERVIEW
● Deadlocks handling in Windows and Linux
● Library hierarchy
● Static vs Dynamic Linking
● Dynamic loading and linking
DEADLOCKS
● A deadlock occurs when two or more tasks permanently block each other by each task having a lock on a resource
which the other tasks are trying to lock.
● Deadlocks occur if following 4 conditions hold simultaneously:
○ Mutual Exclusion
○ Hold and Wait
○ No preemption
○ Circular wait
/lib – Essential Shared Libraries
/lib/iptables
/lib/kbd
OTHER LIBRARY FOLDERS IN LINUX
/lib/modules/'kernel-version'
1. Creating object files: gcc *.c -c -fpic 1. Creating object files: gcc *.c -c -fpic
2. Compiling object files into dynamic 2. Archive the library: ar rcs liball.a *.0
library: gcc *0 -shared -o liball.so 3. Including a prototype for each of the
3. Adding the location for the library file: function that exist in the created library
export LD_LIBRARY_PATH=$PWD:
$LD_LIBRARY_PATH
Dynamic loading and linking within Linux
LINKING:
In Unix-like systems that use ELF for executable images and dynamic libraries, such as Solaris, 64-bit versions of
HP-UX, Linux, FreeBSD, NetBSD, OpenBSD, and DragonFly BSD, the path of the dynamic linker that should be
used is embedded at link time into the .interp section of the executable's PT_INTERP segment. In those systems,
dynamically loaded shared libraries can be identified by the filename suffix .so (shared object).
LOADING:
Loading the library is accomplished with dlopen on UNIX-like operating systems. Examples follow:
Function Description