460 Notes #1
CPTS 460 NOTES #1
PART 1: READING List:
1. Chapter 1 Introduction:
OS as an Extended Machine,
OS as a Resource Manager.
Third and Fourth generation OS
Two key components of an OS; Processes and Files.
OS structures.
2. Page 154-162: Principles of I/O Hardware.
PART 2. BACKGROUND
1. CPU Operation Model:
Every CPU has a Program Counter (PC), a status register (SR), a Stack Poiter
(SP), and many other registers, where
PC --> next instruction in memory;
SR = mode, interruptMask, conditionCode; mode=System/User
SP --> current stack top; may have SSP/USP
The CPU may be modeled by an infinite loop.
while(power_is_on){
(1). fetch instruction :
load *PC as instruction, inc PC;
(2). decode instruction:
each instruction has an op-code and operands
(3). execute the instruction:
may fetch operands from memory and write results to memory;
may use stack, change PC, switch mode, wait or halt.
(4). check any pending INTERRUPTS; may handle interrupts;
}
In each of the above steps, an error condition may occur, e.g.
illegal address, illegal instruction, etc. If so, the CPU traps to
System mode, follows the (pre-installed) pointer at the corresponding
trap vector, and handles the trap condition in software.
2. Computer Hardware:
| CPU |<----- Memory ------> |<------------ I/O devices ---------------> |
| L2 Cache | Main RAM | HardDisks CDROM FloppyDisks Console
cmos RAM KBD,Mouse
ROM (BIOS)
3. System Booting:
(1). PowerOn ===> CPU executes BIOS in ROM :
BIOS initializes itself, then it checks memory and other devices.
Some information needed by BIOS are kept in a small cmos RAM, powered
by a battery.
(2). Then, BIOS looks for a system to boot. The usual booting sequence is A,C,
which can be changed by programming the BIOS (cmos RAM).
First, BIOS tries to boot from drive A: If there is no diskette is A:,
it will try to boot from C:
Booting from a device is to load the FIRST sector of that device into
(segment,offset)=(0000:7C00) and let CPU execute that piece of code.
For a floppy diskette, there is only ONE boot sector. A hard disk is
usually divided into several Partitions, each with its own boot sector.
The very first sector on a HD is called the Master Boot Record (MBR).
(3). Disk Parameters:
All disks for PCs have Sector size = 512 bytes
Every disk has CYL cylinders, H heads, and SECTOR sectors per track.
Examples:
1.44 MB diskette : 80 cylinders, 2 heads, 18 sectors/track
Hard disk : 1010 cylinders, 12 heads, 35 sectors/track
2048 cylinders, 16 heads, 63 sectors/track, etc.
QUESTION#1: Given (CYL,H,SECTOR), determine the disk's capacity in MB.
To issue I/O operations to a disk (controller), we must specify
(cyl, head, sector). BIOS also uses such values in its disk I/O
functions; NOTE: cyl, head count from 0 but sector counts from 1.
(4). Partition Table:
A hard disk can be divided into 4 Primary Partitions. The partitions
are recorded in a Partition Table in the MBR at 0x1BE. Each Partition
Table entry is a structure as shown below.
struct partition {
unsigned char boot_ind; /* 0x80 - active */
unsigned char head; /* starting head */
unsigned char sector; /* starting sector */
unsigned char cyl; /* starting cylinder */
unsigned char sys_ind; /* What partition type */
unsigned char end_head; /* end head */
unsigned char end_sector; /* end sector */
unsigned char end_cyl; /* end cylinder */
unsigned short start_sectlo; /* starting sector counting from 0 */
unsigned short start_secthi; /* starting sector counting from 0 */
unsigned short nr_sectslo; /* nr of sectors in partition */
unsigned short nr_sectshi; /* nr of sectors in partition */
};
Each entry is 16 bytes (for a total of 64 bytes). The last 2 bytes of the
boot sector contain the boot signature 0x55AA.
The Partition Table is usually maintained by programs such as fdisk.
Under Linux, you may use
fdisk /dev/hda or fdisk /dev/hdb
to display, modify the partition tables of C: or D: drive.
The first few bytes are maintained in a format that's convenient for
calling BIOS. Specifically,
BYTE 1 2 3 4
----- ---- ------ -----
drive, head, sector, cyl
Part 3: The Minix Operating System
Minix is a Unix-like operating system. However, its internal organization is
entirely different from Unix. We shall study Minix later as an alterative
approach to OS design.
Part 4: MYX Opearting System
MTX is a Unix-like operating system designed specifically for CS460. The
primary goal of CS460 is to lead you to implement the major components of
MTX. You can download MTX from www.eecs.wsu.edu/~cs460/mtx directory for
testing.