operating systems lecture 31
DESCRIPTION
Dynamic Linking In static linking, system language libraries are linked at compile time and, like any other object module, are combined by the loader into the binary imageTRANSCRIPT
![Page 1: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/1.jpg)
Operating Systems
Lecture 31
![Page 2: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/2.jpg)
Dynamic Linking In static linking, system language libraries are linked at compile time and, like any other object module, are combined by the loader into the binary image
![Page 3: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/3.jpg)
Dynamic Linking In dynamic linking, linking is postponed until run-time.
A library call is replaced by a piece of code, called stub, which is used to locate memory-resident library routine
![Page 4: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/4.jpg)
Dynamic LinkingDuring execution of a process, stub is replaced by the address of the relevant library code and the code is executed
If library code is not in memory, it is loaded at this time
![Page 5: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/5.jpg)
Dynamic LinkingAdvantages
Potentially less time needed to load a program
Potentially less memory space needed
Less disk space needed to store binaries
![Page 6: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/6.jpg)
Dynamic LinkingDisadvantages
Time-consuming run-time activity, resulting in slower program execution
gcc compilerDynamic linking by default-static option allows static linking
![Page 7: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/7.jpg)
OverlaysAllow a process to be larger than the amount of memory allocated to it
Keep in memory only those instructions and data that are needed at any given time
![Page 8: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/8.jpg)
Overlays When other instructions are
needed, they are loaded into the space occupied previously by instructions that are no longer needed
Implemented by user Programming design of overlay
structure is complex and not possible in all cases
![Page 9: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/9.jpg)
Overlays Example2-Pass assembler/compilerAvailable main memory: 150k
Code size: 200kPass 1 ……………….. 70kPass 2 ……………….. 80kCommon routines …... 30kSymbol table ………… 20k
![Page 10: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/10.jpg)
Overlays Example
![Page 11: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/11.jpg)
SwappingSwap out and swap in (or
roll out and roll in)Major part of swap time is
transfer time; the total transfer time is directly proportional to the amount of memory swapped
Large context switch time
![Page 12: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/12.jpg)
Swapping
![Page 13: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/13.jpg)
Cost of SwappingProcess size = 1 MBTransfer rate = 5 MB/secSwap out time = 1/5 sec
= 200 ms
Average latency= 8 msNet swap out time = 208 msSwap out + swap in = 416 ms
![Page 14: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/14.jpg)
Issues with SwappingQuantum for RR schedulerPending I/O for swapped out process
User space used for I/OSolutions
Don’t swap out processes with pending I/O
Do I/O using kernel space
![Page 15: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/15.jpg)
Contiguous AllocationKernel space, user spaceA process is placed in a single contiguous area in memory
Base (re-location) and limit registers are used to point to the smallest memory address of a process and its size, respectively.
![Page 16: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/16.jpg)
Contiguous Allocation
Main Memory
Process
![Page 17: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/17.jpg)
MFTMultiprogramming with fixed tasks (MFT)
Memory is divided into several fixed-size partitions.
Each partition may contain exactly one process/task.
![Page 18: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/18.jpg)
MFTBoundaries for partitions are set at boot time and are not movable.
An input queue per partitionThe degree of multiprogramming is bound by the number of partitions.
![Page 19: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/19.jpg)
Partition 4
Partition 3
Partition 2
Partition 1
OS
MFT100 K
300 K
200 K150 K
Input Queue
s
![Page 20: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/20.jpg)
Potential for wasted memory space—an empty partition but no process in the associated queue
Load-time address binding
MFT With Multiple Input Queues
![Page 21: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/21.jpg)
Single queue for all partitionsSearch the queue for a process when a partition becomes empty
First-fit, best-fit, worst-fit space allocation algorithms
MFT With Single Input Queue
![Page 22: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/22.jpg)
Partition 4
Partition 3
Partition 2
Partition 1
OS
100 K
300 K
200 K150 K
Input Queue
MFT With Single Input Queue
![Page 23: Operating Systems Lecture 31](https://reader036.vdocuments.mx/reader036/viewer/2022070605/5a4d1ae97f8b9ab05997a00b/html5/thumbnails/23.jpg)
Internal fragmentation—wasted space inside a fixed-size memory region
No sharing between processes.
Load-time address binding with multiple input queues
MFT Issues