Introduction to Unix. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Similar documents
Architectural Support for Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

for Operating Systems Computer Systems Laboratory Sungkyunkwan University

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

Introduction to Linux

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo

Architectural Support for OS

CS 201. Exceptions and Processes. Gerson Robboy Portland State University

Today. Introduction to Computer Systems /18 243, Fall th Lecture. Control Flow. Altering the Control Flow.

Exceptional Control Flow Part I Oct. 17, 2002

Altering the Control Flow

Control Flow. Systemprogrammering 2007 Föreläsning 2 Exceptional Control Flow Part I. Exceptional Control Flow. Altering the Control Flow

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Are branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process?

Altering the Control Flow

Exceptional Control Flow Part I

Systems Programming. The Unix/Linux Operating System

Exceptional Control Flow Part I

Exceptional Control Flow Part I September 22, 2008

Today. Exceptional Control Flow Processes. Exceptions and Processes. Control Flow. Altering the Control Flow

LINUX System Administration. Perspectives, Practices and Expectations

Exceptional Control Flow: Exceptions and Processes

Giving credit where credit is due

Exceptions and Processes

OS Interaction and Processes

Unix API Books. Linux Kernel Books. Assignments and Exams. Grading for CSC 256. Operating Systems 8/31/2018. CSC 256/456 Fall

Processes, Exceptional

Operating System. Chapter 3. Process. Lynn Choi School of Electrical Engineering

Cache Example, System Control Flow

Introduction to Linux

Introduction to Operating Systems

Introduction to Linux

CSC 256/456: Operating Systems. Introduction. John Criswell! University of Rochester

UNIX Kernel. UNIX History

Cache Wrap Up, System Control Flow

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

UNIT I Linux Utilities

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 18

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Introduction to Operating Systems. Jo, Heeseung

Threads Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Introduction to Computer Systems , fall th Lecture, Oct. 7 th

INTRODUCTION TO OPERATING SYSTEMS. Jo, Heeseung

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Introduction to Cygwin Operating Environment

CSE 153 Design of Operating Systems Fall 18

Exceptional Control Flow Part I Oct. 28, 2009"

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

CMPSC 311- Introduction to Systems Programming Module: UNIX/Operating Systems

CSE 153 Design of Operating Systems

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

hardware interrupts software interrupts

Lecture 01: welcome and intro what LSD and Unix have in common

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS420: Operating Systems. OS Services & System Calls

Kernel Types Simple OS Examples System Calls. Operating Systems. Autumn CS4023

UNIT I Linux Utilities and Working with Bash

Overview of Unix / Linux operating systems

Computer Systems Laboratory Sungkyunkwan University

Unix System Architecture, File System, and Shell Commands

CSE351 Inaugural Edi7on Spring

Department of Computer Science and Technology, UTU 2014

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

High Performance Computing Lecture 11. Matthew Jacob Indian Institute of Science

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Are branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process?

Introduction to the basics of UNIX

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system.

Operating System Architecture. CS3026 Operating Systems Lecture 03

Excep&onal Control Flow: Excep&ons and Processes

CS 5460/6460 Operating Systems

CNT 4603, Spring 2009: Introduction

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

(MCQZ-CS604 Operating Systems)

CS450/550 Operating Systems

Basics of system administration on a Unix system

Chapter 2: Operating-System Structures

File System Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

(In columns, of course.)

CSE 120 Principles of Operating Systems

Problem Set: Processes

Chap2: Operating-System Structures

Welcome to CIS 90 Introduction to UNIX/Linux

MEMORY MANAGEMENT IN UNIX. STUDENT NAME : AMAL ISWIASI STUDENT NO: PRESENT TO : Prof. Dr. Hasan Huseyin Balik

COPYRIGHTED MATERIAL. Unix Fundamentals. Brief History

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

Reserves time on a paper sign-up sheet. Programmer runs his own program. Relays or vacuum tube hardware. Plug board or punch card input.

Exceptions and Processes

What is a Process. Processes. Programs and Processes. System Classification 3/5/2013. Process: An execution stream and its associated state

Operating Systems CS3502 Spring 2018

The Operating System Machine Level

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Excep onal Control Flow: Excep ons and Processes

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes

CMPSC 311- Introduction to Systems Programming Module: UNIX/Operating Systems

Four Components of a Computer System

Multitasking. Programmer s model of multitasking. fork() spawns new process. exit() terminates own process

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

Operating Systems CS 571

Computer Systems Laboratory Sungkyunkwan University

Chapter 4 Multithreaded Programming

Transcription:

Introduction to Unix Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

What is an OS? OS is a resource manager Sharing Protection Fairness Performance OS provides the program execution environment Hides the messy details which must be performed. Presents users with a virtual machine, easier to use. 2

Unix (1) Unix is Interactive Time-sharing Multi-tasking Multi-user Flavors of Unix System V (AT&T USL Novell SCO Caldera SCO) BSD (UC Berkeley) SunOS, Solaris (Sun) IRIX (SGI), AIX (IBM), HP-UX (HP), Mac OS X (Apple) Linux, FreeBSD, NetBSD, etc. 3

Unix (2) Unix history and motivation Originally developed at AT&T Bell Labs for internal use in the early 1970s. Borrowed best ideas from other OS s. Unix was developed by programmers and for programmers. cryptic names special characters and notation around 400 standard utilities documentation is short on examples and tutorials Unix is designed so that users can extend the functionality to build new tools easily and efficiently. 4

Unix (3) Why Unix? Used in many scientific and industrial settings Huge number of free and well-written software programs Open-source OS (Linux, FreeBSD, etc.) Internet servers and services run on Unix Largely hardware-independent Based on standards Many important OS concepts are developed on Unix. Android! 5

OS Internals (1) User Application C Library (libc) User space System Call Interface Kernel space Kernel Arch-dependent kernel code Hardware Platform 6

OS Internals (2) User space shell ls trap shell ps Kernel space File System Management I/O Management (device drivers) System Call Interface Memory Management Process Management scheduler IPC synchronization Protection Hardware Control (Interrupt handling, etc.) Hardware 7

OS Internals (3) OS is a special software between applications and hardware. When does the OS take control of the system? Bootstrapping System calls Interrupts OS is an event-driven software. trap System call Interrupts Hardware 8

Exceptions An exception is a transfer of control to the OS in response to some event. User Process OS event current next exception exception processing by exception handler exception return (optional) 9

Handling Exceptions Vector table Each type of event has a unique exception number k. Index into jump table (interrupt vector) Jump table entry k points to a function (exception handler) Handler k is called each time exception k occurs. 0 1 2 n-1 Exception numbers interrupt vector... code for exception handler 0 code for exception handler 1 code for exception handler 2... code for exception handler n-1 10

Asynchronous Exceptions Interrupts Caused by events external to the processor Indicated by setting the processor s interrupt pin Handler returns to next instruction. Examples I/O interrupts» Hitting a key at the keyboard» Arrival of a packet from a network» Arrival of a data sector from a disk Hard reset interrupt» Hitting the reset button Soft reset interrupt» Hitting CTRL-ALT-DELETE on a PC 11

Synchronous Exceptions Traps Intentional System calls, breakpoint traps, special instructions, etc. Returns control to next instruction Faults Unintentional but possibly recoverable page faults (recoverable), protection faults (unrecoverable), etc. Either re-executes faulting ( current ) instruction or aborts Aborts Unintentional and unrecoverable Parity error, machine check, etc. Aborts current program 12

Fault Example (1) Memory reference: invalid User writes to memory location Address is not valid Page handler detects invalid address Sends SIGSEGV signal to user process User process exits with segmentation fault int a[1000]; main () { a[5000] = 13; } User Process OS event movl page fault Detect invalid address Signal process 13

Fault Example (2) Memory reference: valid but not resident User writes to memory location That portion (page) of user s memory is currently on disk. Page handler must load page into physical memory Returns to faulting instruction Successful on second try. User Process OS int a[1000]; main () { a[500] = 13; } event movl return page fault Create page and load into memory 14

Trap Example Opening a file User calls open (filename, options) Function open executes system call instruction int 0804d070 < libc_open>:... 804d082: cd 80 int $0x80 804d084: 5b pop %ebx OS must find or create file, get it ready for reading or writing. Returns integer file descriptor User Process OS int pop exception return 15

POSIX Standards IEEE Standard 1003.x POSIX is a standard that describes a single interface to a Unix-like operating system. 1003.1 System Application Program Interface (Kernel) 1003.2 Shell and Utilities 1003.4 Real-time Extensions 1003.7 System Administration, etc. POSIX is not an implementation it is a description! Most system vendors are now conforming to POSIX standards (specifically IEEE 1003.1) Even Microsoft provides a set of POSIX utilities with the Windows NT 4.0 Resource Kit. 16

POSIX System Calls Process Management File Management File System Management fork waitpid execve exit kill open close read write lseek stat chmod mkdir rmdir link unlink mount umount chdir Create a new process Wait for a process to exit Load a new binary image Terminate execution Send a signal Create a file or open an existing file Close a file Read data from a file Write data to a file Move the file pointer Get various file attributes Change the file access permission Create a new directory Remove an empty directory Make a link to a file Destroy an existing file Mount a file system Unmount a file system Change the curent working directory......... 17

Summary You need to master Unix/Linux. OS is an event-driven software. Trap is a pathway to the kernel. OS provides various services via system calls. 18