CS 149: Operating Systems May 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak www.cs.sjsu.edu/~mak
Unofficial Field Trip Extra credit fun quiz! Computer History Museum in Mt. View http://www.computerhistory.org/ Saturday, May 9, 11:30 – closing time Special free admission. Do a self-guided tour of the new Revolution exhibit. See a life-size working model of Charles Babbage’s Difference Engine in operation, a hand-cranked mechanical computer designed in the early 1800s. Experience a fully restored IBM 1401 mainframe computer from the early 1960s in operation. General info: http://en.wikipedia.org/wiki/IBM_1401 My summer seminar: http://www.cs.sjsu.edu/~mak/1401/ Restoration: http://ed-thelen.org/1401Project/1401RestorationPage.html Extra credit fun quiz!
Four Eras of Microsoft Operating Systems MS-DOS Windows 1.0, 2.0 MS-DOS-based Windows Windows 3.0, 3.1, 98, ME NT-based Windows Windows XP, Vista, 7 Modern Windows Windows 8, 8.1
Modern Windows Microsoft transformed itself from a PC software company to a devices and services company. Needed an OS that it could deploy across phones tablets game consoles laptops desktops servers cloud
MinWin Approach A small OS core that can be extended into different devices. Extend the core to be the operating systems for specific devices. New user interfaces and features Common experience for users Support new Intel architectures. Support the ARM architecture.
Modern Windows Programming Layers Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Programming Windows Windows 8.1 removed POSIX compliance. Modern Software Development Kit Includes the new WinRT set of APIs. Shift programmers away from a threading model to a task model. Separate resource management (priorities, CPUs) from the programming model (concurrent activities). Modern applications run in an AppContainer sandbox for security.
Components to Build NT Subsystems The NT kernel contains general-purpose facilities for writing OS-specific subsystems. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Kernel-Mode Objects The NTOS executive layer running in kernel mode implements system calls. Native NT system calls operate on kernel-mode objects: Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Native NT API Native NT API calls use handles to manipulate objects across process boundaries. Examples: Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Win32 API Library procedures that either Do the work in user mode. Wrap native NT calls that do the work: Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Windows-on-Windows (WOW) Used on 32-bit x86 systems. Run 16-bit Windows 3.x applications. Map system calls and parameters between the 16-bit and 32-bit worlds. WOW64 Allows 32-bit applications to run on x64 systems.
Windows vs. Unix Unix Windows Simple OS functions Few parameters Few examples of multiple ways to do something. Kernel panic for a fatal error. Windows Comprehensive APIs with many parameters. Several ways to do the same thing. Mixed low-level and high-level functions. Blue Screen of Death for a fatal error.
Windows Registry Registry: A special file system to maintain system configuration information. Hive: A volume of the registry. HKLM = HKEY LOCAL MACHINE Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Kernel-Mode Organization ISR = Interrupt Service Routine DPC = Deferred Procedure Call APC = Asynchronous Procedure Call LPC = Local Procedure Call Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Dispatcher Objects Control dispatching and synchronization: events mutexes semaphores threads timers Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Executive Layer Object manager I/O manager Manages most kernel-mode objects Processes, threads, files, semaphores, I/O devices and drivers, timers, etc. I/O manager Framework for implementing I/O device drivers. Executive services to configure, access, and perform operations on devices. Plug-and-play
Executive Layer, cont’d Process manager Create and terminate processes and threads Memory manager Demand-paged virtual memory Physical page frames Disk pagefile backing store Cache manager Optimizes I/O performance
Executive Layer, cont’d Security reference monitor Enforces Windows security mechanisms Supports Common Criteria U.S. Department of Defense Orange Book requirements Configuration manager Implements the registry Advanced local procedure call (ALPC) Highly efficient interprocess communication
Hardware Abstraction Layer (HAL) Hide machine dependencies. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Device Stacks IRP = I/O request packet Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Object Management Most important function of the executive. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Object Handles Handles refer to kernel-mode objects. A handle table translates handles to objects. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Handle Table A handle table can have up to 16 million handles. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Object Procedures Supplied when specifying a new object type. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Object Namespace Directories Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Creating and Opening a File Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Creating and Opening a File, cont’d Executive component passes Unicode pathname for namespace. Object manager searches through directories and symbolic links. Object manager calls the Parse procedure for object type. I/O manager creates IRP, allocate file object, send request to stack of I/O devices. IRP passed down the I/O stack until it reaches device object representing the file system instance.
Creating and Opening a File, cont’d Device objects encountered as the IRP heads toward the file system represent file system filter drivers. File system device object has a link to file system driver object. NTFS fills in file object and returns it to I/O manager, which returns back up through all devices on the stack. Object manager is finished with its namespace lookup. Final step is to return back to the user-mode caller.
Common Executive Object Types Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Processes and Threads Processes can optionally be grouped into jobs. A thread can schedule multiple fibers. A fiber assumes the identity of the thread that runs it. Lower overhead of switching among threads. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Processes and Threads, cont’d Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Processes and Threads, cont’d Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Thread Priorities Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Thread Priorities, cont’d Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Memory Management Virtual address space layout Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Memory Management System Calls Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Page Fault Categories The page referenced is not committed. committed = the page is mapped to a virtual page Attempted access to a page that is in violation of the permissions. A shared copy-on-write page was about to be modified. The stack needs to grow. The page referenced is committed but not currently mapped in. These first two are due to programming errors. LRU page replacement algorithm.
I/O API Calls Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
Device Driver Stacking Stack device drivers to work with a specific instance of a device. Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620
File System A volume is the fundamental structure of the Windows 8.1 file system (NTFS). Created by the Windows 8.1 disk administrator utility. Based on a logical disk partition. May occupy a portions of a disk, an entire disk, or span across several disks. All metadata, such as information about the volume, is stored in a regular file.
NTFS Clusters A cluster is the underlying unit of disk allocation. A cluster is a number of disk sectors that is a power of 2. Because the cluster size is smaller than for the 16-bit FAT file system, the amount of internal fragmentation is reduced.
File System Logging All file system data structure updates are performed inside transactions that are logged. Before a data structure is altered, the transaction writes a log record that contains redo and undo information. After the data structure has been changed, a commit record is written to the log to signify that the transaction succeeded.
File System Recovery After a crash, the file system data structures can be restored to a consistent state by processing the log records. This scheme does not guarantee that all the user file data can be recovered after a crash. It only guarantees that the file system data structures (the metadata files) are undamaged and reflect some consistent state prior to the crash.
Security Secure login with anti-spoofing measures Discretionary access controls Privileged access controls Address space protection per process New pages must be zeroed before being mapped in Security auditing
Security, cont’d Each user and group identified by an SID (security ID). Each process has an access token containing: a SID a DACL (default access control list) other properties DACL Modern Operating Systems, 4th ed. Andrew Tanenbaum and Herbert Bos Pearson, 2014 ISBN: 978-0133591620