The Plan Today... System Calls and API's Basics of OS design Virtual Machines



Similar documents
Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Operating System Structures

OPERATING SYSTEMS STRUCTURES

System Structures. Services Interface Structure

OS Virtualization Frank Hofmann

CS3600 SYSTEMS AND NETWORKS

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Kernel Types System Calls. Operating Systems. Autumn 2013 CS4023

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Operating System Structure

x86 ISA Modifications to support Virtual Machines

W4118 Operating Systems. Junfeng Yang

Operating System Structures

64-Bit NASM Notes. Invoking 64-Bit NASM

Components of a Computer System

Chapter 2 System Structures

Example of Standard API

Chapter 3 Operating-System Structures

Virtual Machines. Virtualization

Virtualization Technologies

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Encryption Wrapper. on OSX

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edition

COS 318: Operating Systems

Operating System Organization. Purpose of an OS

COS 318: Operating Systems. Virtual Machine Monitors

How To Write A Windows Operating System (Windows) (For Linux) (Windows 2) (Programming) (Operating System) (Permanent) (Powerbook) (Unix) (Amd64) (Win2) (X

Operating System Components

Operating System Components and Services

ELEC 377. Operating Systems. Week 1 Class 3

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

Virtual machines and operating systems

Full and Para Virtualization

Virtualization. Pradipta De

Virtual Servers. Virtual machines. Virtualization. Design of IBM s VM. Virtual machine systems can give everyone the OS (and hardware) that they want.

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Operating Systems. Rafael Ramirez (T, S)

OS Concepts and structure

Virtualization. Types of Interfaces

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

12. Introduction to Virtual Machines

Multi-core Programming System Overview

CPS221 Lecture: Operating System Structure; Virtual Machines

CS161: Operating Systems

Outline. Outline. Why virtualization? Why not virtualize? Today s data center. Cloud computing. Virtual resource pool

CS420: Operating Systems OS Services & System Calls

Lecture 1 Operating System Overview

Clouds, Virtualization and Security or Look Out Below

Uses for Virtual Machines. Virtual Machines. There are several uses for virtual machines:

Virtual Machines.

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure


Introduction to Virtual Machines

Star System Deitel & Associates, Inc. All rights reserved.

Database Access via Programming Languages

Virtualization System Vulnerability Discovery Framework. Speaker: Qinghao Tang Title:360 Marvel Team Leader

Virtualization Technology. Zhiming Shen

Cloud^H^H^H^H^H Virtualization Technology. Andrew Jones May 2011

Virtualization. Jia Rao Assistant Professor in CS

Operating- System Structures

Distributed and Cloud Computing

Chapter 3: Operating-System Structures. Common System Components

IOS110. Virtualization 5/27/2014 1

Tools Page 1 of 13 ON PROGRAM TRANSLATION. A priori, we have two translation mechanisms available:

Virtual Hosting & Virtual Machines

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

Virtualization. Jukka K. Nurminen

COM 444 Cloud Computing

Project Adding a System Call to the Linux Kernel

OPERATING SYSTEM SERVICES

Virtualization for Cloud Computing

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

kvm: Kernel-based Virtual Machine for Linux

Virtual Machine Monitors. Dr. Marc E. Fiuczynski Research Scholar Princeton University

Enabling Technologies for Distributed Computing

CHAPTER 1: OPERATING SYSTEM FUNDAMENTALS

Operating Systems OS Architecture Models

An Implementation Of Multiprocessor Linux

CPET 581 Cloud Computing: Technologies and Enterprise IT Strategies. Virtualization of Clusters and Data Centers

CS197U: A Hands on Introduction to Unix

Operating Systems 4 th Class

Operating Systems Virtualization mechanisms

Download Virtualization Software Download a Linux-based OS Creating a Virtual Machine using VirtualBox: VM name

Leveraging Thin Hypervisors for Security on Embedded Systems

Automatic Logging of Operating System Effects to Guide Application-Level Architecture Simulation

Distributed System Monitoring and Failure Diagnosis using Cooperative Virtual Backdoors

3 - Introduction to Operating Systems

Operating Systems and Networks

Lecture 25 Symbian OS

Virtualization. Introduction to Virtualization Virtual Appliances Benefits to Virtualization Example Virtualization Products

Return-oriented programming without returns

Andreas Herrmann. AMD Operating System Research Center

Transparent Monitoring of a Process Self in a Virtual Environment

The Art of Virtualization with Free Software

Virtual Machine Security

Chapter 6, The Operating System Machine Level

Why Threads Are A Bad Idea (for most purposes)

Transcription:

System Calls +

The Plan Today... System Calls and API's Basics of OS design Virtual Machines

System Calls System programs interact with the OS (and ultimately hardware) through system calls. Called when a user level program needs a service from the OS. Generally written in C/C++ Execute in kernel mode code can access protected hardware. Can't be called like a normal function (more soon...)

Types of System Calls Process control File management Device management Information maintenance Communications Message passing Shared memory Protection

Application Programming Interface Application code generally does not invoke system calls directly. Programmer calls functions defined by an API. Win32 API (Windows OSs) POSIX API (Most Unix-like OS's) You can check it out at http://www.unix.org/single_unix_specification/ Basically a bunch of C header files along with precise, legalistic, descriptions of functionality.

Win32 API Example 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

Unix API Invocation Example

More Linux Trivia In Linux API is provided by glibc: GNU libc. That's why you'll hear GNU/Linux OS. You still don't have a useful computer until you get some application programs. That's where distributions come in. Debian, Fedora, Ubuntu etc.

Why Use an API? API tends to be more programmer friendly than direct system calls. Designing an OS involves trade-offs between ease of use, and ease of implementation. System calls driven by ease of implementation API driven by ease of use. Some API calls are basically wrappers for system calls. Some are much more complex. Coding to an API results in more portable code.

How Do System Calls Work? (In Linux) Initiated by a software interrupt. Architecture dependent. On x86 architectures: Every interrupt has a unique number. Copy appropriate number to register eax. Copy syscall parameters to registers: ebx, ecx, edx, esi, edi (for up to five parameters.) Put an address in a register for more than five. Execute software interrupt instruction: int $0x80

API Example #include <stdlib.h> int main () { exit(0); }

Direct syscall Example #include <stdio.h> #include <sys/syscall.h> #define NR_getppid 64 int main() { printf("%d\n", syscall( NR_getppid )); }

strace Let's look at an example...

An Aside: Macros C preprocessor can define entities to be expanded in the code. #define BIGNUM 999999... if (a > BIGNUM) printf( a is huge. ); Macros can take parameters... #define max(a,b) (A) > (B)? (A) : (B)... printf( max of c and d is %d\n, max(c,d)); It's just simple text substitution.

How Does Linux Handle the System Call? There is architecture dependent code in arch/whatever_architecture. Assembly code for handling system calls is in: arch/x86/kernel/entry_32.s ( or _64. S) (Until recently it was: arch/i386/kernel/entry.s) Other interesting locations: arch/x86/kernel/syscall_table_32.s kernel/sys.c

OS Design: Separate Policy and Mechanism How to do something (mechanism) vs. what should be done (policy). E.g. There needs to be a mechanism to swap out interactive process every N milliseconds. N should not be part of the implementation.

OS Design: Basic Organization Early OS designs were not particularly modular: MS-Dos Some more principled approaches: Layered OS Micro-Kernel Modular OSs

Layered Design Challenges: Not always clear what should go in each layer Overhead in moving from one layer to the next.

Micro-Kernels Kernel only provides some very basic functionality: Process management. Process communication via message passing. Everything else is handled by user level code. Advantages: Easy to get a small Kernel right. Easy to port a small Kernel. Elegant design. Main disadvantage: slow.

Modular OS Most modern operating systems (including Linux) implement kernel modules. Uses object-oriented approach. Each core component is separate. Each talks to the others over known interfaces. Each is loadable as needed within the kernel. Modules interact through normal function calls. Not much overhead at run time.

Virtual Machines Allow us to simultaneously run multiple OS's on a single computer. Many uses: OS design and testing. Maintaining legacy systems. Honeypots

Implementing VMs You can emulate every hardware instruction in software, e.g. Bochs. Performance is not good. Relatively easy to get an OS running. You can depend on functionality from the host OS, e.g. User Mode Linux Instructions run directly on hardware, system calls are captured and sent to host OS. Easier if client OS is similar to host OS. Better performance. Other VM systems: VMWare, Xen, VirtualBox

Acknowledgments Portions of these slides are taken from Power Point presentations made available along with: Silberschatz, Galvin, and Gagne. Operating System Concepts, Seventh Edition. Original versions of those presentations can be found at: http://os-book.com/