Unformatted text preview:

The Tempo Operating System Part 4 System Initialization Last Edit 9 13 2007 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 or processor reset is found in various Read Only Memories ROMs 1 ROMs Found in Machines Most important ROM contains the BIOS the 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 for SCSI devices BIOS Startup Actions POST power on self test Validate the hardware configuration Identify devices e g serial parallel USB ports disk CD DVD drives PnP devices etc reporting configuration in RAM Invoke initialization code in option ROMs Assign non conflicting memory and interrupt resources to configurable devices e g those on PCI buses Allow user configuration of boot sequence date time etc Search boot devices in a specified order for a bootable device Copy the first sector from the bootable device into memory at 0x7c00 and then transfer control to it 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 However more recent BIOS capabilities include some 32 bit protected mode services Only very simple operating systems will continue to use these functions after the operating system is loaded 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 CP M applications were written to run starting at 0x100 The Radio Shack TRS 80 computer had ROM in lowmemory and so application providers had to make a separate versions for the TRS 80 that avoided the memory occupied by ROM the 8080 had no hardware facilities for simple relocation of program code and no virtual memory 3 The Boot Sector The boot sector at least on IA 32 contains 512 bytes including a jump instruction to location x to skip over the partition table a partition table for hard disk partitions identifies bootable and non bootable regions of the boot drive 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 Tempo s Boot Sector Since Tempo wasn t designed to be booted from a hard disk perhaps a bad decision that will be changed in the future 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 4 Other Bootstrap Sequences Other systems may use a multistage bootstrap process The boot sector loads a small second stage bootstrap loader things like grub in the Linux world The second stage loader then brings in the operating system perhaps from a compressed image instead of a flat image as with Tempo Once the system is booted the memory occupied by the bootstrap loader is no longer needed and can be reused for other purposes 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 in kernel s to finish initialization 5 Protected Mode Initialization kernel s Set kernel segment registers Set kernel stack pointer Zero memory expected to be zero by C bss and COMMON Identify the memory available in the system Clear the display show system version message and setup the page map array which tracks page usage Initialize the keyboard Load the IDT register Initialize the priority interrupt controller s masking unused interrupts Initialize the interval timer for 1 msec interrupts Turn on paging Call tempo in sys c which never returns 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 execution at Main and then running the first user process 6 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 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 7 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 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 8 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 priority If disk I O is enabled check for a hard disk and for a filesystem 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


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?