Presentation on theme: "W EEK S IX O PERATING S YSTEM S TRUCTURE. T HE C ONCEPT OF L OADING AND L INKING Loader – Loader is a utility program which takes object code as input,"— Presentation transcript:
W EEK S IX O PERATING S YSTEM S TRUCTURE
T HE C ONCEPT OF L OADING AND L INKING Loader – Loader is a utility program which takes object code as input, prepares it for execution and loads the executable code into memory. Loader is actually responsible for initiating the execution process. Functions of loaders Allocating – Loader calculates the size of executable program and allocates memory space. This activity is called allocation. Linking – It resolves the symbolic references (code/data) between the object modules, by assigning all the user subroutine and library subroutine addresses. This activity is called linking. Relocation – There are some address dependent locations in a program, such address constants must be adjusted according to allocated space, such activity done by loader is called relocation. Loading – It places all the machine instructions and data of corresponding programs and subroutines into the memory. Thus program now becomes ready for execution and this activity is called loading.
L OADER S CHEMES Compile and go loader – The instruction is read line by line, its machine code is obtained and it is directly put into the memory at some known address. This means assembler is run in one part of the memory and the assembled machine instructions and data is directly put into their assigned memory addresses. After this process, starting address of the program is assigned to the location counter. Disadvantages: Requires more memory as assembler needs to use some portion of memory No object file (.obj), the source is directly converted to executable form. Hence no modification is required but source code needs to be assembled and executed each time. Thus it becomes a time consuming activity. It cannot handle multiple source or programs written in multiple languages as one assembler cannot translate source from different languages. More execution time is required as every time the program needs to be assembled and then executed Advantages: Easy to implement as assembler is placed at one part of the memory and loader simply loads assembled machine instructions into memory
L OADER S CHEMES General Loader – Source code is translated into object program by some assembler. The loader accepts these object modules and puts machine instructions and data in an executable form at their assigned memory. Loader requires some memory. Advantages: Program need not to be translated every time as source code is already in object code format. More memory is available for program as assembler is not occupying any memory. It is possible to write source code in multiple languages as the object is already translated by corresponding assemblers
G ENERAL L OADER S CHEME Source Program Translator Object Program 1 Object Program 2 Loader Executable Object Code Loader Program Main Memory
L OADER S CHEMES Absolute Loader –Is a kind of loader which accepts relocated object files and place them at specified locations in memory. It is called absolute as no relocation information is needed; it is provided by the programmer or assembler. Programmer needs to have the knowledge of memory management Issues of any external references or linking of any sub-routines need to be carried out by programmer. Specific address of each module needs to be provided by programmer When branching out, absolute address is to be known by programmer.
L OADER S CHEMES Absolute Loader Advantages: Simple to implement Allows to write multiple programs or source programs in multiple languages. Assemblers provide object code with all address resolutions. The task of loader becomes simpler as it just needs to obey instructions. The execution process is efficient. Disadvantages: o Programmer needs to know about memory management.
L OADER S CHEMES Direct Link Loaders The most common type of loader This type is a re-locatable loader There are two situations to place address at appropriate location in the memory Absolute address Relative Address Assembler informs the loader about relative address Address of all segments which are not defined in the current segment but can be used in the current segment The list of all segments which are defined in the current segment but can be used by other segments
L INKAGE E DITOR The execution of a program needs four functionalities : allocation, relocation, linking and loading Program that performs allocation, relocation and linking is called binder The binder which performs the linkage function and produces adequate information about allocation and relocation and writes this information along with program is called linkage editor.
P ROCESS OF L INKING AND L OADING Translator Linker Loader Output Given to Output Loaded into Memory
O PERATING S YSTEM D ESIGN AND I MPLEMENTATION Design and implementation of OS not “solvable” but some approaches have been proven successful Internal structure of different operating systems can vary widely Start by defining goals and specifications Affected by choice of hardware, type of system User goals and system goals User goals – operating system should be convenient to use easy to learn, reliable, safe and fast System goals – operating system should be easy to design, implement and maintain, as well as flexible, reliable, error-free, and efficient
O PERATING S YSTEM D ESIGN AND I MPLEMENTATION Important principle to separate Policy -What will be done? Mechanism – How to do it? Mechanisms determine how to do something, policies what will be done The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later
S IMPLE S TRUCTURE MS DOS MD DOS – Written to provide the most functionality in the least space Not divided into modules Although MS DOS has some structure, its interfaces and functionality are not very well separated
MS DOS L AYER S TRUCTURE
L AYERED A PPROACH The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0) is the hardware; the highest (layer n) is the user interface With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers
T RADITIONAL U NIX S YSTEM S TRUCTURE
UNIX UNIX- Limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX Operating System consists of two separable parts System Programs Kernel Consists of every thing below the system- call interface, and above the physical hardware Provides the file system, CPU scheduling, memory management and other operating system functions: a large number of functions for one level
L AYERED O PERATING S YSTEM
M ICROKERNEL S YSTEMM Moves as much from the kernel into “user” space Communication takes place between user modules using message passing Benefits Easier to extend a microkernel Easier to port the operating system to new architectures More reliable (less code is running in kernel mode) More secure Detriments Performance overhead of user space to kernel space communication
M ODULES Most modern operating systems implement kernel mode User object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel Overall, similar to layers but with more flexibility
S OLARIS M ODULAR A PPROACH
V IRTUAL M ACHINES A virtual machine takes the layered approach to its logical conclusion. It treats the hardware and operating system kernel as though they were all hardware A virtual machine provides an interface identical to the underlying bare hardware The operating system host creates the illusion that a process has its own processor and (virtual memory) Each guest provided with virtual (copy) of underlying computer
V IRTUAL M ACHINE Non Virtual Machine Virtual Machine
V IRTUALIZATION I MPLEMENTATION Difficult to implement – must provide an exact duplicate of underlying machine Typically runs in user mode, creates virtual user mode and virtual kernel mode Timing can be an issue - slower than real machine Hardware support needed More support –> better virtualization i.e. AMD provides “host” and “guest” modes
S OLARIS 10 W ITH T WO C ONTAINERS
VM WARE A RCHITECTURE
T HE JAVA V IRTUAL M ACHINE
O PERATING S YSTEM D EBUGGING Debugging is finding and fixing errors, or bugs OSes generate log files containing error information Failure of application can generate core dump file capturing memory of the process Operating system failure can generate crash dump file containing kernel memory Beyond crashes, performance tuning can optimize system performance
S OLARIS 10 D TRACE F OLLOWING S YSTEM C ALL
S YSTEM B OOT Operating Systems must be made available to hardware so that hardware can start it Small piece of code-bootstrap loader, locates the kernel, loads it to memory, start it Sometimes two – step where boot block at fixed location loads bootstrap loader When power initialized on system, execution starts at a fixed memory location Firmware used to hold initial boot code