Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M030 30 th November, 2008.

Slides:



Advertisements
Similar presentations
CSC 360- Instructor: K. Wu Overview of Operating Systems.
Advertisements

Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 3 Operating System Organization.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Figure 1.1 Interaction between applications and the operating system.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
OS Spring’04 Introduction Operating Systems Spring 2004.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Protection and the Kernel: Mode, Space, and Context.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Implementing Processes and Process Management Brian Bershad.
Introduction to Operating Systems Chapter 1. cs431 -cotter2 Lecture Objectives Understand the relationship between computing hardware, operating system,
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
1 Operating System Overview. 2 Today’s Objectives Explain the main purpose of operating systems and describe milestones of OS evolution Explain fundamental.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Chapter 3 Process Description and Control
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 E-Main: Phone:
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Background: I/O Concurrency Brad Karp UCL Computer Science CS GZ03 / M030 2 nd October, 2008.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Processes Introduction to Operating Systems: Module 3.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Introduction to Operating Systems and Concurrency.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Department of Computer Science and Software Engineering
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
OSes: 2. Structs 1 Operating Systems v Objective –to give a (selective) overview of computer system architectures Certificate Program in Software Development.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
Introduction to Operating Systems Concepts
Applied Operating System Concepts
Process Management Process Concept Why only the global variables?
CS 6560: Operating Systems Design
Protection of System Resources
Lecture Topics: 11/1 Processes Process Management
Operating Systems: A Modern Perspective, Chapter 6
Operating Systems and Systems Programming
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Lecture Topics: 11/1 General Operating System Concepts Processes
LINUX System : Lecture 7 Lecture notes acknowledgement : The design of UNIX Operating System.
Implementing Processes, Threads, and Resources
CS510 Operating System Foundations
Outline Operating System Organization Operating System Examples
Outline Process Management Process manager Hardware process
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Operating System Concepts
Operating System Concepts
Chapter 1: Introduction CSS503 Systems Programming
Presentation transcript:

Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008

2 Outline Goals of an operating system Sketch of UNIX –User processes, kernel –Process-kernel communication –Waiting for I/O Simple web server design

3 Why Discuss OS Now? Real distributed systems run on an OS OS details affect design, robustness, performance –Sometimes because of OS idiosyncrasies –More often because OS already solves some hard problems Ask questions if something isn’t clear! Further reading: –General overview: Tanenbaum, Modern Operating Systems, 2 nd Edition –Details of a modern UNIX: McKusick et al., The Design and Implementation of the 4.4 BSD Operating System

4 Goals of OS Designers Share hardware resources –e.g., one CPU, many applications running Protection (app-to-app, app-to-OS) –Bug in one app shouldn’t crash whole box or bring down other app Communication (app-to-app, app-to-OS) Hardware independence –Don’t want to rewrite apps for each new CPU, each new I/O device How? Using abstractions and well-defined interfaces

5 UNIX Abstractions Process –Address space –Thread of control –User ID Filesystem File Descriptor –File on disk –Pipe between processes –Network connection –Hardware device

6 OS Virtualizes Hardware Kernel implements abstractions, executes with privilege to directly touch hardware OS multiplexes CPU, memory, disk, network among multiple processes (apps) Apps can share resources Apps can control resources Apps see simple interface

7 OS Abstraction Design OS abstractions interact –If can start program, must be able to read executable file Processes see system call interface to kernel abstractions –Looks like function call, but special –e.g., fork(), exec() –e.g., open(), read(), creat()

8 Typical UNIX System App1 and App2 in separate address spaces; protected from one another Hardware runs kernel with elevated privilege Kernel User Space Filesystem Disk Driver Hardware App1App2 libs 00 N M How do processes and kernel communicate? How do processes and kernel wait for events (e.g., disk and network I/O)?

9 System Calls: Process-Kernel Communication Application closes a file: close(3); C library: close(x) { R0 <- 73 R1 <- x TRAP RET }

10 System Calls: Traps TRAP instruction: XP <- PC switch to kernel address space set privileged flag PC <- address of kernel trap handler Kernel trap handler: save regs to this process’ “process control block” (PCB) set SP to kernel stack call sys_close(), ordinary C function …now executing in “kernel half” of process… restore registers from PCB TRAPRET

11 System Calls: TRAPRET TRAPRET instruction: PC <- XP clear privileged flag switch to process address space continue execution

12 System Call Properties Protected transfer –Process granted kernel privilege level by hardware –But jump must be to known kernel entry point Process suspended until system call finishes What if system call must wait (e.g., read() from disk)?

13 Blocking I/O On a busy server, system calls often must wait for I/O; e.g., sys_open(path) for each pathname component start read of directory from disk sleep waiting for disk read process directory contents sleep() save kernel regs to PCB1 (including SP) find runnable PCB2 restore PCB2 kernel registers (SP, &c.) return Each user process has kernel stack contains state of pending system call System call ”blocks” while awaiting I/O

14 Disk I/O Completion How does process continue after disk I/O completes? Disk controller generates interrupt Device interrupt routine in kernel finds process blocked on that I/O Marks process as runnable Returns from interrupt Process scheduler will reschedule waiting process

15 How Do Servers Use Syscalls? Consider server_1() web server (in handout) time application CPU disk syscalls network syscalls Server waits for each resource in turn Each resource largely idle What if there are many clients? R RWW R C

16 Performance and Concurrency Under heavy load, server_1(): –Leaves resources idle –…and has a lot of work to do! Why? –Software poorly structured! –What would a better structure look like?

17 Solution: I/O Concurrency Can we overlap I/O with other useful work? Yes: –Web server: if files in disk cache, I/O wait spent mostly blocked on write to network –Networked file system client: could compile first part of file while fetching second part Performance benefits potentially huge –Say one client causes disk I/O, 10 ms –If other clients’ requests in cache, could serve 100 other clients during that time! Next time: how to achieve I/O concurrency!