Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Secondary Storage Management of Introduction to Operating Systems | CS 333, Study notes of Operating Systems

Material Type: Notes; Professor: Walpole; Class: INTRO TO OPERATING SYSTEMS; Subject: Computer Science; University: Portland State University; Term: Spring 2007;

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-h97-1
koofers-user-h97-1 🇺🇸

5

(1)

10 documents

1 / 68

Toggle sidebar

Related documents


Partial preview of the text

Download Secondary Storage Management of Introduction to Operating Systems | CS 333 and more Study notes Operating Systems in PDF only on Docsity! CS 333 Introduction to Operating Systems Class 16 – Secondary Storage Management Jonathan Walpole Computer Science Portland State University But first ... a Continuation of discussion on I/O devices Programmable clocks One-shot mode: Counter initialized then decremented until zero At zero a single interrupt occurs Square wave mode: At zero the counter is reinitialized with the same value Periodic interrupts (called “clock ticks”) occur Time 500 MHz Crystal (oscillates every 2 nanoseconds) 32 bit register overflows in 8.6 seconds So how can we remember what the time is? Backup clock Similar to digital watch Low-power circuitry, battery-powered Periodically reset from the internet UTC: Universal Coordinated Time Unix: Seconds since Jan. 1, 1970 Windows: Seconds since Jan. 1, 1980 Goals of clock software Maintain time of day Must update the time-of-day every tick Prevent processes from running too long Account for CPU usage Separate timer for every process Charge each tick to the current process Handling the “Alarm” syscall User programs ask to be sent a signal at a given time Providing watchdog timers for the OS itself E.g., when to spin down the disk Doing profiling, monitoring, and statistics gathering Block vs character devices Clocks just interrupt, there’s no data to input or output Other devices input/output data Character (byte) at a time (i.e. terminals) Block at a time (i.e. disks) Terminals Terminal hardware Serial line unit (SLU) for asynchronous bit-serial communication RS-232 / Serial interface / Modem / tty / COM UART: Universal Asynchronous Receiver Transmitter byte → serialize bits → wire → collect bits → byte Registers for control, status, input and output of data Input software Character processing User types “hella←o” Computer echoes as: “hella←_←o” Program will see “hello” Raw mode The driver delivers all characters to application process No modifications, no echoes vi, emacs, the BLITZ emulator, password entry Cooked mode The driver does echoing and processing of special chars. “Canonical mode” Cooked mode The terminal driver must... Buffer an entire line before returning to application Process special control characters • Control-C, Backspace, line-erase, tabs Echo the character just typed Accommodate type-ahead • Ie., it needs an internal buffer ! • Example of producer consumer problem Approach 1 (for computers with many terminals) Have a pool of buffers to use as necessary Approach 2 (for single-user computer) Have one buffer (e.g., 500 bytes) per terminal Central buffer pool vs. dedicated buffers Terminal Terminal data structure data structure Central Terminal buffer pool Terminal 0 1 aa 0 Buffer 2 area for ) terminal 0 ) 1 Buffer area for terminal 1 Control-D: EOF Typing Control-D (“End of file”) causes the read request to be satisfied immediately Do not wait for “enter key” Do not wait for any characters at all May return 0 characters Within the user program count = Read (fd, buffer, buffSize) if count == 0 -- Assume end-of-file reached... Outputting to a terminal The terminal accepts an “escape sequence” Tells it to do something special Example: esc [ 3 ; 1 H esc [ 0 K esc [ 1 M Each terminal manufacturer had a slightly different specification Makes device independent software difficult Unix “termcap” file • Database of different terminals and their behaviors. Move to position (3,1) on screen Erase the line Shift following lines up one ESCAPE: 0x1B ANSI escape sequence standard Escape sequence Meaning ESC [nA Move up nlines ESC [nB Move down n lines ESC [nC Move right n spaces ESC [nD Move left 7 spaces ESC [m;nH Move cursor to (m,n) ESC [sJ Clear screen from cursor (0 to end, 1 from start, 2 all) ESC [sk Clear line from cursor (0 to end, 1 from start, 2 all) ESC [nL Insert rn lines at cursor ESC [nM Delete n lines at cursor ESC [nP Delete n chars at cursor ESC [n@ Insert n chars at cursor ESC [nm Enable rendition n (O=normal, 4=bold, 5=blinking, 7=reverse) ESC M Scroll the screen backward if the cursor is on the top line Graphical user interfaces (GUIs) Graphics CPU Memory adapter Video Video |— controller RAM ; ‘ ——————— Bus 7 Analog <—] A\ video signal X Window System Client – Server architectures Basd on Remote Procedure Calls (RPC) • Client makes a call. • Server is awakened; the procedure is executed. Intelligent terminals (“X terminals”) The display side is the server. The application side is the client. The application (client) makes requests to the display server. Client and server are separate processes • (May be on the same or different machines) X window system Remote host ‘a Window Application X terminal manager program Motif User < Intrinsics space Xlib X client X server Bias (_ Kernel UNIX UNIX space Hardware Hardware hy: X protocol Network Disk geometry Disk head, surfaces, tracks, sectors … cylinder Track Sector Comparison of (old) disk technology Parameter IBM 360-KB floppy disk | WD 18300 hard disk Number of cylinders 40 10601 Tracks per cylinder 2 12 Sectors per track 9 281 (avg) Sectors per disk 720 35742000 Bytes per sector 512 512 Disk capacity 360 KB 18.3 GB Seek time (adjacent cylinders) 6 msec 0.8 msec Seek time (average case) 77 msec 6.9 msec Rotation time 200 msec 8.33 msec Motor stop/start time 250 msec 20 sec Time to transfer 1 sector 22 msec 17 usec Disk zones Constant rotation speed • Want constant bit density Inner tracks: • Fewer sectors per track Outer tracks: • More sectors per track Disk formatting A disk sector Typically 512 bytes / sector ECC = 16 bytes Cylinder skew Sector interleaving No Interleaving Single Interleaving Double Interleaving Disk scheduling algorithms First-come first serve Shortest seek time first Scan back and forth to ends of disk C-Scan only one direction Look back and forth to last request C-Look only one direction Shortest seek first (SSF) Initial Pending position ; requests \ i \ X X] |XX X X] 1X 0 5 10 15 20 25 30 35 Cylinder _ Sequence of seeks a —~—Time Shortest seek first (SSF) Cuts arm motion in half Fatal problem: Starvation is possible! Other disk scheduling algorithms First-come first serve Shortest seek time first Scan back and forth to ends of disk C-Scan only one direction Look back and forth to last request C-Look only one direction Errors on disks Transient errors v. hard errors Manufacturing defects are unavoidable Some will be masked with the ECC (error correcting code) in each sector Dealing with bad sectors Allocate several spare sectors per track At the factory, some sectors are remapped to spares Errors may also occur during the disk lifetime The sector must be remapped to a spare By the OS By the device controller Using spare sectors Substituting a new sector Shifting sectors Stable storage Use two disks for redundancy Each write is done twice Each disk has N blocks. Each disk contains exactly the same data. To read the data ... you can read from either disk To perform a write ... you must update the same block on both disks If one disk goes bad ... You can recover from the other disk Stable storage Stable write Write block on disk # 1 Read back to verify If problems... • Try again several times to get the block written • Then declare the sector bad and remap the sector • Repeat until the write to disk #1 succeeds Write same data to corresponding block on disk #2 • Read back to verify • Retry until it also succeeds Stable storage Stable Read Read the block from disk # 1 If problems... • Try again several times to get the block If the block can not be read from disk #1... • Read the corresponding block from disk #2 Our Assumption: • The same block will not simultaneously go bad on both disks Stable storage Disk blocks can spontaneously decay Given enough time... The same block on both disks may go bad • Data could be lost! Must scan both disks to watch for bad blocks (e.g., every day) Many variants to improve performance Goal: avoid scanning entire disk after a crash. Goal: improve performance • Every stable write requires: 2 writes & 2 reads • Can do better... RAID Redundant Array of Independent Disks Redundant Array of Inexpensive Disks Goals: Increased reliability Increased performance (Stipa | siipt) [Stine | | sis] Strip 11 Strip 8 Strip 9 Strip 10] | Strip 11 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 (c) RAID level 2 CDs & CD-ROMs CD-ROMs 32x CD-ROM = 5,000,000 Bytes/Sec SCSI-2 is twice as fast. CD-R (CD-Recordable) Dark spot in the dye layer burned [by laser when writing Printed label Protective Tacquer Reflective gold layer Dye layer 1.2mm Y Polycarbonate Substrate Direction of motion Pen Lens Y Photodetector | Prism Infrared ~—— laser diode Updating write-once media VTOC = Volume Table of Contents When writing, an entire track is written at once. Each track has its own VTOC. Upon inserting a CD-R, Find the last track Obtain the most recent VTOC • This can refer to data in earlier tracks This tells which files are on the disk Each VTOC supercedes the previous VTOC Deleting files? CD-RW Uses a special alloy Alloy has two states, with different reflectivities Crystalline (highly reflective) - Looks like “land” Amorphous (low reflectivity) - Looks like a “pit” Laser has 3 powers Low power: Sense the state without changing it High power: Change to amorphous state Medium power: Change to crystalline state DVDs “Digital Versatile Disk” Smaller Pits Tighter Spiral Laser with different frequency Transfer speed 1X = 1.4MB/sec (about 10 times faster than CD) Capacity 4.7 GB Single-sided, single-layer (7 times a CD-ROM) 8.5 GB Single-sided, double-layer 9.4 GB Double-sided, single-layer 17 GB Double-sided, double-layer
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved