Unformatted text preview:

The Tempo vm Operating System Part 4 System Initialization 1 A Bare Machine A bare machine doesn t automatically begin executing the operating system and processes when the power switch is pushed Instead it must go through loads of code before the first user process ever gets a chance to run The only code available to the CPU on powerup is found in various Read Only Memories ROMs 2 1 ROMs Found in Machines Most important contains BIOS Basic I O System see next slide Other ROMs contain code functions and data structures that are unique to the I O devices in the machine called option ROMS video devices usually called the video BIOS network interface cards NICs for network booting disk adapter code especially SCSI devices 3 BIOS Startup Actions POST power on self test validate hardware configuration identify devices e g serial parallel USB ports disk CD DVD drives PnP devices etc invoke initialization code in option ROMs Optional allow user configuration Search boot devices in specified order for a bootable device Load first sector of bootable device in memory at 0x7c00 and transfer to it 4 2 Additional BIOS Features In addition to getting the first sector of a bootable device into RAM a BIOS provides a set of functions for performing simple input output operations These usually operate in real mode without external interrupt support and are intended primarily to help get an operating system into memory Only very simple operating systems will continue to use these functions after system startup 5 An Aside on Standards As an example of why standards are important even in the BIOS world consider the early days of PCs using the Intel 8080 and the CP M operating system without any virtual memory or protection Most machines had ROM at a fixed location high memory and most CP M applications were written to run starting at 0x100 The Radio Shack TRS 80 computer had ROM in low memory and so application providers had to make a separate version for the TRS 80 6 3 The Boot Sector The boot sector at least on IA 32 contains 512 bytes including a jump instruction to location x 512 a partition table for hard disk partitions at x code to read from additional disk sectors into memory and then jump to them a boot signature 0xaa55 that allows the BIOS to recognize a valid boot sector 7 Tempo s Boot Sector Since Tempo wasn t designed to be booted from a hard disk perhaps a bad decision that will be changed the entire boot sector is used for code there is no partition table The code in bootstrap bsp s loads the entire system into memory starting at physical address 0x8000 and then transfers to it at start in realio s 8 4 Real Mode Startup realio s Setup the initial stack grows downward from 0x8000 Setup the TSS Task State Segment descriptor Setups values to be used for the GDT global descriptor table and IDT interrupt descriptor table registers Loads the GDT register Switches to protected mode Jumps to do pm kernel s to finish initialization 9 Protected Mode Initialization kernel s Set kernel segment registers Set kernel stack pointer Zero memory expected to be zero by C Compute memory available in the system Clear the display show system version message and setup the page map array Initialize the keyboard Load the IDT register Initialize the priority interrupt controller s masking unused interrupts Setup the interval timer Turn on paging Call tempo in sys c which never returns 10 5 Tempo sys c C Code Finally We re still in kernel mode but we re running code written in C tempo is responsible for major OS data structure initialization creating the idle and first user process which begins at Main and then running the first user process 11 OS Data Structures OS data structures can be allocated in two ways statically a fixed sized pool array of typed objects used as required and returned to the pool when no longer needed dynamically available memory pool is untyped pieces are allocated for objects as needed There are advantages and disadvantages to each approach 12 6 Static Allocation Advantages No memory fragmentation Allocation and deallocation is fast Code is simpler Linear searches can be used to identify a specific object s in a pool of objects with the same type 13 Dynamic Allocation Advantages All available memory can potentially be used with static allocation decisions must be made about the number of objects of each type before the system runs and running out of one type of object can cause system failure even though there may be unused memory in the pool of objects of a different type 14 7 Tempo s Allocation Design Tempo uses static allocation for the major OS data structures The size of the structures are defined in the h sysparm h file Examples define define define define define NPROC 10 NSEMA 20 NMSGS 256 NQUEUE 8 NKEYS 128 number of process table entries in proctab number of semaphores in sematab number of messages in msgtab number of message queues per process maximum queued keyboard inputs 15 OS Initialization 1 Mark all process table entries as unused Allocate first semaphore for CS macro Allocate second semaphore for keyboard Mark other semaphores as unused Create pool of message nodes Clear the ready queues one for each prio If disk I O is enabled check for a hard disk and for a filesystem 16 8 OS Initialization 2 Set number of processes to 0 Set the sleep delta queue to empty Clear the disk I O request queue Set pid for first process Setup the idle process proctab entry call addready to add it to its ready queue Setup the Main process proctab entry call addready to add it to its ready queue Set activeProcess to NULL Call xmain to begin process execution 17 addready Process p Process is equivalent to struct Proc a pointer to a proctab entry The addready function sets the state of the process to ready adds it to the end of the queue for its priority Note that the idle process pid 0 has priority 1 so 1 is added to a process priority when indexing the array of ready queue head pointers called readyList 18 9 Process getready void Set newProcess to NULL Search from the highest priority down for a non empty ready queue If a non empty queue is found remove the entry at the head of the queue pointing to it with newProcess If newProcess is still NULL halt the system with appropriate error message Otherwise return newProcess 19 10


View Full Document

UNO CSCI 8530 - System Initialization

Loading Unlocking...
Login

Join to view System Initialization and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view System Initialization and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?