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

Computer Systems and Operating Systems: Structure and I/O Subsystem - Prof. Michael W. Hic, Study notes of Operating Systems

An overview of computer systems and operating systems, focusing on the i/o subsystem. It covers various types of i/o devices, their performance characteristics, and synchronous and asynchronous i/o. The document also discusses storage structure, caching, and secondary storage management. Additionally, it touches upon operating system services, resource allocation, accounting, protection, and secondary-storage-related functions.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-31m
koofers-user-31m 🇺🇸

10 documents

1 / 9

Toggle sidebar

Related documents


Partial preview of the text

Download Computer Systems and Operating Systems: Structure and I/O Subsystem - Prof. Michael W. Hic and more Study notes Operating Systems in PDF only on Docsity! 1 1 CMSC 412 Spring 2007 Computer System and Operating System Structure Announcements • Project #0 – Due Friday • Project #1 – Much harder than Project #0! – Posted Friday • Reading – Chapter 1, 2 Computer Systems I/O Subsystem Structure • Many different types of devices – disks – networks – displays – mouse – keyboard • Each has different peak performance – bandwidth • rate at which data can be moved – latency • time from request to first data back Performing I/O • Synchronous – OS issues I/O request, and waits for it to complete before continuing. • Asynchronous – OS issues request, and then does something else. Device generates interrupt to notify OS of completion. • Direct Memory Access (DMA) – A kind of async I/O, but for larger blocks rather than single characters/bytes Storage Structure • Main memory – only large storage media that the CPU can access directly – DRAM, SRAM (Caches) • Secondary storage – extension of main memory that provides large nonvolatile storage capacity – Disks (floppy disks, hard disk, optical disk) – Tape drives, Zip drives – Flash RAM (somewhere in between?) 2 2 Storage Hierarchy • Storage systems organized in hierarchy. – Speed – Cost – Volatility • Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage. Storage-Device Hierarchy Caching • Use of high-speed memory to hold recently-accessed data. • Requires a cache management policy. • Caching introduces levels in storage hierarchy. This requires data that is simultaneously stored in more than one level to be consistent. Migration of “A” From Disk to Register Storage Performance Operating System Services • Program execution – Load a program into memory and to run it. • I/O operations • File-system manipulation • Communications – Between local or distributed processes – Either shared memory or message passing. • Error detection and recovery – In the CPU and memory hardware, in I/O devices, or in user programs. 5 5 Win32 API Example • Consider the ReadFile() function in the • Win32 API—a function for reading from a file • A description of the parameters passed to ReadFile() – HANDLE file—the file to be read – LPVOID buffer—a buffer where the data will be read into and written from – DWORD bytesToRead—the number of bytes to be read into the buffer – LPDWORD bytesRead—the number of bytes read during the last read – LPOVERLAPPED ovl—indicates if overlapped I/O is being used POSIX (stdio) Example • C program invoking printf() library call, which calls write() system call System Call Mechanism • Number indicates what call is made • Parameters in registers or on the stack • Why do we use system call numbers rather than directly calling a kernel subroutine? – permits changing the size and location of system call implementations without having to re-link application programs GeekOS and x86 • Intel system call instruction – int n where n is the interrupt vector # – “call kernel routine n” – vectors 0-31 reserved • Page fault, segmentation violation, etc. • GeekOS – All system calls set n as 90 – System call number stored in eax register Types of System Calls • File Related – open, create, read, write, close, delete – get or set file attributes • Informational – get time – set system data (OS parameters) – get process information (id, time used) • Communication Related – establish a connection; terminate a connection – send, receive messages • Process control – create/terminate a process (including self) Use of a System Call for I/O 6 6 Why use system calls at all? • Why not “link” application programs against the kernel and call kernel routines directly? – (What IS a kernel anyway, and why do we need it?) Answer: Protection • Need to protect OS from user programs and user programs from each other – Don’t want a bug in a user program to crash the whole machine (as in earlier OSs, like MS-DOS, MacOS, Windows 3.1, and others) • Hardware resources of interest – Memory, I/O devices, CPU Dual-Mode Operation • Provide hardware support to differentiate between at least two modes of operations. 1. User mode – execution for a user. 2. Monitor mode (also kernel mode or system mode) – execution done on behalf of operating system. • Operations in user mode a subset of those allowed in monitor mode – Privileged instructions only in monitor Dual-Mode Operation • Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1). X86 actually has 4 modes (2 bits). • When an interrupt or fault occurs hardware switches to monitor mode. monitor user Interrupt/fault set user mode I/O Protection • System call mechanism prevents user mode programs from accessing devices directly. – All I/O instructions are privileged • But what if user program can overwrite interrupt handler with its own code? Memory Protection • Must provide memory protection at least for the interrupt vector and the interrupt service routines. • In order to have memory protection, add two registers that determine the range of legal addresses a program may access: – Base register – holds the smallest legal physical memory address. – Limit register – contains the size of the range • Memory outside the defined range is protected. 7 7 Base and Limit Registers Hardware Address Protection Changing the base and limit registers are privileged operations CPU Protection • Timer – interrupts computer after specified period to ensure operating system maintains control. – Timer is decremented every clock tick. – When timer reaches the value 0, an interrupt occurs. • Commonly used to implement time sharing. • Load-timer is a privileged instruction. OS Implementation • What language should I build my OS in? – High- vs. low-level languages • How should I structure it to manage complexity? – Balance reliability, maintainability, and performance OS Structure: Simple • Any part of the system may use the functionality of the rest of the system – MS-DOS (user programs can call low level I/O routines) OS Structure: Layered • Layer n can only see the functionality that layer n-1 exports – abstracts the lower level details •new hardware can be added if it provides the interface required of a particular layer – system call interface is an example of layering
Docsity logo



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