1 / 30

Week Six Operating System Structure

Week Six Operating System Structure. The Concept of Loading and Linking. 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.

lysa
Download Presentation

Week Six Operating System Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week Six Operating System Structure

  2. The Concept of Loading and Linking • 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.

  3. Loader Schemes • 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

  4. Loader Schemes • 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

  5. General Loader Scheme Source Program Translator Object Program 1 Loader Executable Object Code Source Program Translator Object Program 2 Loader Program Main Memory

  6. Loader Schemes • 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.

  7. Loader Schemes • 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: • Programmer needs to know about memory management.

  8. Loader Schemes • 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

  9. Linkage Editor • 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.

  10. Process of Linking and Loading Linker Translator Given to Output Output Loader Given to Loaded into Memory

  11. Operating System Design and Implementation • 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

  12. Operating System Design and Implementation • 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

  13. Simple Structure 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

  14. MS DOS Layer Structure

  15. Layered Approach • 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

  16. Traditional Unix System Structure

  17. 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

  18. Layered Operating System

  19. Microkernel Systemm • 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

  20. Modules • 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

  21. Solaris Modular Approach

  22. Virtual Machines • 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

  23. Virtual Machine Non Virtual Machine Virtual Machine

  24. Virtualization Implementation • 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

  25. Solaris 10 With Two Containers

  26. VMware Architecture

  27. The JAVA Virtual Machine

  28. Operating System Debugging • 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

  29. Solaris 10 Dtrace Following System Call

  30. System Boot • 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

More Related