chapter 2 introduction to os chien-chung shen cis, ud [email protected]

8
Chapter 2 Introduction to OS Chien-Chung Shen CIS, UD [email protected]

Upload: daniella-scott

Post on 05-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Chapter 2Introduction to OS

Chien-Chung ShenCIS, UD

[email protected]

Operating System

• Goal: make the system easy to use (or run programs)– run many programs at the same time– allow programs to share memory– enable programs to interact with devices– etc.

• How: virtualization – take a physical resource (e.g., processor, memory, or disk) and transform it into a more general, powerful, and easy-to-use virtual form of itself– refer OS as a virtual machine

Virtual Machine (VM)

• To allow users to tell OS what to do and thus make use of the features of VM (e.g., run programs, allocate memory, access files), OS provide interfaces (APIs) that can be called– system calls and standard library

• OS as resource manager– virtualization– concurrency– persistency

Virtualization

• How to virtualize resources?– policies and mechanisms

• Virtualize CPU– cpu.c and common.h– ./cpu A & ; ./cpu B &; ./cpu C &

• Virtualize memory– mem.c (with address-space

randomization disabled)

Concurrency

• Working on many things at once (concurrently) in the same program– OS itself– multithreaded programs– threads.v0.c (race condition)– threads.v1.c (atomic)

Persistence

• DRAM is volatile• Disk (hard drive) and solid-state

drive (SSD)• File system (the part of OS that

manages disk/SSD and files)• io.c• Sharing of disks

Design Goals of OS

• Build abstraction• Provide high performance and

minimize OS overhead• Provide protection between

applications via isolation• Reliability • Energy efficiency• Security• Mobility

System Calls

• User applications run in user mode which means hardware restricts what applications can do (e.g., I/O requests)

• A system call transfers control (i.e., jumps) into the OS while simultaneously raising the hardware privilege level (kernel mode)

• When a system call is initiated (via special hardware instruction trap), hardware transfers control to a prespecified trap handler (that OS set up previously) and simultaneously raises the privilege level to kernel mode

• When OS is done servicing the request, it passes control back to the user via a special return-from-trap instruction, which reverts to user mode while simultaneously passing control back to where the application left off