COP3402 Lecture11
COP3402 Lecture11
Loaders
Text
Data
Absolute loader: Header The absolute loader will load the program at memory location x200: 1.- The header record is checked to verify that the correct program has been presented for loading. Text section 2.- Each text record is read and moved to the indicate address in memory 3.- When the end record (EOF) is encountered, the loader jumps to the specified address to begin execution.
Data section
Data Heap
Text section
Bootstrapping continued
n
This program does not have the full functionality of an operating system, but it is capable of loading into memory a more elaborated software (i.e. loader2) which in its turn will load the operating system. Once the OS has been loaded the loader transfers the control of the computer system to the operating system.
Bootstrapping continued
n
Early programmable computers had toggle switches on the front panel to allow the operator to place the bootloader into the program store before starting the CPU. In modern computers the bootstrapping process begins with the CPU executing software contained in ROM at a predefined address whose elementary functionality is to search for devices eligible to participate in booting, and load a small program from a special section of a device.
Bootstrapping continued
CPU MEMORY
I/O OPERATIONS
BOOT PROG
I/O
ROM OS
LOADER 2
Bootstrapping continued
CPU MEMORY LOADER2
I/O OPERATIONS
BOOT PROG
I/O
ROM OS
LOADER 2
Bootstrapping continued
n
In earlier computers data had to be hand loaded as specified before, but nowadays a small piece of software called loader helps us to avoid the manual loading.
0 99998 100000
LC = Location Counter
READ
LOADER 2 0
LC
LC + 1
IF (EOF) PC
Bootstrapping continued
CPU OS LOADER2
I/O OPERATIONS
BOOT PROG
I/O
ROM OS
LOADER 2
Bootstrapping continued
n
The above diagram can be explained in the following steps. 1. Check hardware 2. Initiate I/O to load the loader 2 program into memory 3. Loader 2 loads the OS and passes control to it
Conclusion
n
We have seen that once the OS has control over the system , it can create an environment for programs to run. The operating system will load device drivers and other programs that are needed for the normal operation of the computer system.
Operating system
Definition:
A program in execution An asynchronous activity The locus of control of a procedure in execution It is manifested by the existence of a process control block (PCB) in the operating system.
The activity of a process is controlled by a data structure called Process Control Block(PCB). A PCB is created every time a program is loaded to be executed. So, a process is defined by a PCB-Program couple.
..
S T A C K
Program
Load PCB
OS
code
stack
Process Creation
Create
Disk
Dynamic link, return address, Local variables, function Parameters, Dynamically allocated variables static Global and variables / initialized data Constants Program text (write protected)
stack
Loc# 00
text 13 33 35
Loc# 40
text 13 73 75
before relocation
Loc# 00 03 06 08 10 12 14 16 18 20 22 25
28
after relocation
Loc# 40 43 46 48 50 52 54 56 58 60 62 65 68 70 text 13 13 12 08 03 02 07 06 01 08 73 75 74 76 78 76 75 76 77 78 70 77
Len 3 3 2 2 2 2 2 2 2 2 3 3 2
reloc
text 33 35 34 36
br comp write limit stop CONST CONST SPACE SPACE SPACE SPACE 0 1
30 32 33 34 35 36 37 38
36 35 37 36 38
13 76 75 13 77 76 00 50 08 78
Interleaving relocation bits with the program text makes cumbersome the process of loading the text directly into memory. This problem can be resolve by collecting all relocation bits into a single contiguous relocation map that we will call the relocation section of the object code file (ELF). The relocation section will be appended to the text and data sections. The header will contain the entry point and length of the relocation section in the object module.
Header
Text section
Data section
Relocation section
The end