CS 3204 Operating Systems

CS 3204 Operating Systems Lecture 30 Godmar Back Announcements Project 3 due April 13 Th Apr 6, 7pm, 655 McBryde: attend townhall meeting regarding planned restructuring of 6th floor undergrad space CS 3204 Spring 2006 02/28/20 2 Kernel-level vs User-level Threads M:N Model Solaris Lightweight Processes

CS 3204 Spring 2006 02/28/20 4 M:N Model (contd) Invented for use in Solaris OS early 90s Championed for a while Idea was to get the best of both worlds Fast context switches if between user-level threads Yet enough concurrency to exploit multiple CPUs Since abandoned in favor of kernel-level threads only approach Too complex whats the right number of LWP? 2-level scheduling/resource management was hard: both user/kernel operated with half-blind CS 3204 Spring 2006 02/28/20

5 Multi-Threading in Linux Went through different revisions Today (Linux 2.6): NPTL Next-Generation POSIX Thread Library 1:1 model optimizes synchronization via futexes avoids mode switch for common case of uncontended locks by performing atomic operation constant-time scheduling operation allow for scaling in number of threads CS 3204 Spring 2006 02/28/20 6 Summary Memory Management Address Spaces vs Protection Domains Kernel vs User-Level Threads

CS 3204 Spring 2006 02/28/20 7 Disks & Filesystems What Disks Look Like Hitachi Deskstar T7K500 SATA CS 3204 Spring 2006 02/28/20 9 How Disks Work Flash Animation See http://cis.poly.edu/cs2214rvs/disk.swf

CS 3204 Spring 2006 02/28/20 10 Disk Schematics Source: Micro House PC Hardware Library Volume I: Hard Drives CS 3204 Spring 2006 02/28/20 11 Typical Disk Parameters

2-30 heads (2 per platter) Diameter: 2.5 14 Capacity: 20MB-500GB Sector size: 64 bytes to 8K bytes Most PC disks: 512 byte sectors 700-20480 tracks per surface 16-1600 sectors per track CS 3204 Spring 2006 02/28/20 12 Whats important about disks from OS perspective Disks are big & slow - compared to RAM Access to disk requires Seek (move arm to track) to cross all tracks anywhere from 2050ms, on average takes 1/3. Rotational delay (wait for sector to appear under track) 7,200rpm is 8.3ms per rotation, on average takes : 4.15ms rot delay Transfer time (fast: 512 bytes at 998 Mbit/s is about 3.91us)

Seek+Rot Delay dominates Random Access is expensive and unlikely to get better Consequence: avoid seeks seek to short distances amortize seeks by doing bulk transfers CS 3204 Spring 2006 02/28/20 13 Disk Scheduling Can use priority scheme Can reduce avg access time by sending requests to disk controller in certain order Or, more commonly, have disk itself reorder requests SSTF: shortest seek time first

Like SJF in CPU scheduling, guarantees minimum avg seek time, but can lead to starvation SCAN: elevator algorithm Process requests with increasing track numbers until highest reached, then decreasing etc. repeat Variations: LOOK dont go all the way to the top without passengers C-SPAN: - only take passengers in one direction CS 3204 Spring 2006 02/28/20 14 Accessing Disks Sector is the unit of atomic access Writes to sectors should always complete, even if power fails Consequence: Writing a single byte requires read-modifywrite void

voidset_byte(off_t set_byte(off_toff, off,char charb) b){{ }} char charbuffer[512]; buffer[512]; disk_read(disk, disk_read(disk,off/DISK_SECTOR_SIZE, off/DISK_SECTOR_SIZE,buffer); buffer); buffer[off buffer[off% %DISK_SECTOR_SIZE] DISK_SECTOR_SIZE]==b; b; disk_write(disk, disk_write(disk,off/DISK_SECTOR_SIZE,

off/DISK_SECTOR_SIZE,buffer); buffer); CS 3204 Spring 2006 02/28/20 15 Disk Caching Buffer Cache How much memory should be dedicated for it? In older systems (& Pintos), set aside a portion of physical memory In newer systems, integrated into virtual memory system: e.g., page cache in Linux How should prefetching be done? How should concurrent access be mediated (multiple processes may be attempting to write/read to same sector)? How is consistency guaranteed? (All must go through buffer cache!)

What write-back strategy should be used? CS 3204 Spring 2006 02/28/20 16 Buffer Cache in Pintos Cache Block Descriptor - disk_sector_id, if in use - dirty bit - valid bit - # of readers - # of writers - # of pending read/write requests - lock to protect above variables - signaling variables to signal availability changes - usage information for eviction policy - data (pointer or embedded)

desc 512 bytes desc 512 bytes desc 512 bytes desc 512 bytes 64 desc 512 bytes desc

512 bytes desc 512 bytes CS 3204 Spring 2006 02/28/20 17 A Buffer Cache Interface ////cache.h cache.h struct ////opaque structcache_block; cache_block; opaquetype type

////reserve reserveaablock blockininbuffer buffercache cachededicated dedicatedto tohold holdthis thissector sector ////possibly possiblyevicting evictingsome someother otherunused unusedbuffer buffer ////either eithergrant grantexclusive exclusiveor orshared

sharedaccess access struct structcache_block cache_block**cache_get_block cache_get_block(disk_sector_t (disk_sector_tsector, sector,bool boolexclusive); exclusive); ////release releaseaccess accessto tocache cacheblock block void voidcache_put_block(struct cache_put_block(structcache_block cache_block*b); *b); ////read

readcache cacheblock blockfrom fromdisk, disk,returns returnspointer pointerto todata data void void*cache_read_block(struct *cache_read_block(structcache_block cache_block*b); *b); ////fill fillcache cacheblock blockwith withzeros, zeros,returns returnspointer pointerto

todata data void void*cache_zero_block(struct *cache_zero_block(structcache_block cache_block*b); *b); ////mark markcache cacheblock blockdirty dirty(must (mustbe bewritten writtenback) back) void voidcache_mark_block_dirty(struct cache_mark_block_dirty(structcache_block cache_block*b); *b); ////not

notshown: shown:initialization, initialization,readahead, readahead,shutdown shutdown CS 3204 Spring 2006 02/28/20 18

Recently Viewed Presentations

  • In case you are interested in the regulatory history…

    In case you are interested in the regulatory history…

    A consumer account that involves multiple payments or transactions, such as a loan or account that is billed or payable in installments ... PCI DSS, GLB) focuses on data security in order to avoid theft of personal, confidential information. ......
  • Bacteriostatic Inhibitors of Protein Synthesis

    Bacteriostatic Inhibitors of Protein Synthesis

    Almost always with Sulfamethoxazole: TMP-SMZ aka Septra, Bactrim Uses UTI Pneumocystis carinii, esp immunocompromise Fluoroquinolones Broad spectrum antibiotics Uses: Pneumonia, UTIs, sinusitis, skin infections, bones, everything Mechanism of action Inhibition of bacterial DNA gyrase Adverse effects GI reactions, dizziness, headache,...
  • Adrenergic drugs The adrenergic drugs affect receptors that

    Adrenergic drugs The adrenergic drugs affect receptors that

    βReceptorsexhibitasetofresponsesdifferentfromthose ofthe α receptors.. These are characterized by a strong response to isoproterenol ...
  • Presentación de PowerPoint - GitLab

    Presentación de PowerPoint - GitLab

    The Basque Fab Lab DenokInn DenokInn is the Basque Centre for Innovation, Entrepreneurship and New Business Development. DenokInn promotes a comprehensive approach towards innovation in order to identify and promote new business opportunities and services in existing firms and/or within...
  • Aims - BIU

    Aims - BIU

    Inhibition The ability to deliberately ignore and filter distracting responses or thoughts, and distracting irrelevant information held in working Memory (e.g., Baddeley, 1996; Baddeley et al., 1998). Shifting (mental flexibility) The ability to switch attention back and forth between mental...
  • Vincent van Gogh

    Vincent van Gogh

    Domy v Auvers, 1890 často umisťuje tmavý předmět vlevo do středu je vložen hlavní objekt Co je typické pro van Goghovu malbu? pro van Gogha je typické silné reliéfní nanášení čistých barev, které střídají čáry a plochy vyjadřující pohyb Co...
  • Research Methodology By Peerayuth (Pete) Charoensukmongkol, Ph.D. Assistant

    Research Methodology By Peerayuth (Pete) Charoensukmongkol, Ph.D. Assistant

    Concomitant variation—two phenomena vary together. Occur when two events "covary" or "correlate" X increases when Y increased X decreases when Y increased
  • Uncontrolled copy not subject to amendment Airmanship Knowledge

    Uncontrolled copy not subject to amendment Airmanship Knowledge

    Tutor T1 Reporting Name: Tutor Role Letters and Marks: T1 Role: Primary Trainer Tutor T1 The Grob 115E aircraft entered Royal Air Force service in 1999 as the Tutor T1, replacing the Bulldog at UAS and AEFs The RAF Tutor...