COP4610: Operating Systems Project 1

Similar documents
Changes made in this version not seen in first lecture:

EEE3052: Introduction to Operating Systems. Fall Project #1

Processes (Intro) Yannis Smaragdakis, U. Athens

6.828: Using Virtual Memory. Adam Belay

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017

W4118: interrupt and system call. Junfeng Yang

ICS143A: Principles of Operating Systems. Lecture 14: System calls (part 2) Anton Burtsev November, 2017

Project 1 System Calls

CS 4414 Operating System Introduction

CS Lab 1 xv6 Introduction Setup and exercise

CS3210: Isolation Mechanisms

Operating Systems Engineering Recitation #3 (part 2): Interrupt and Exception Handling on the x86. (heavily) based on MIT 6.

4. The Abstraction: The Process

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

Ausgewählte Betriebssysteme. Anatomy of a system call

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I Solutions. Mean 70.5 Median 72 Standard deviation 15.8 Kurtosis -0.

3. Process Management in xv6

Processes and Threads

Processes. q Process concept q Process model and implementation q Multiprocessing once again q Next Time: Scheduling

1 Programs and Processes

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2

Machine Program: Procedure. Zhaoguo Wang

Mechanisms for entering the system

CSC369 Lecture 2. Larry Zhang

CS5460/6460: Operating Systems. Lecture 9: First process. Anton Burtsev January, 2014

CSC369 Lecture 2. Larry Zhang, September 21, 2015

LAB 2: PROCESS SYNCHRONIZATION IN XV6

Section 4: Threads and Context Switching

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

ECE 391 Exam 1 Review Session - Spring Brought to you by HKN

Protection and System Calls. Otto J. Anshus

CSE 153 Design of Operating Systems Fall 18

Assembly Language: Function Calls

Processes. Today. Next Time. Process concept Process model Implementing processes Multiprocessing once again. Scheduling processes

Assembly Language: Function Calls" Goals of this Lecture"

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

CS 537 Lecture 2 - Processes

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems

Operating Systems. Part 8. Operating Systems. What is an operating system? Interact with Applications. Vector Tables. The master software

Introduction. This project will focus primarily on processes.

Project 3 - Virtual Memory Simulator. Simulate memory page allocation and page eviction algorithm

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

W4118: PC Hardware and x86. Junfeng Yang

CS 31: Intro to Systems Functions and the Stack. Martin Gagne Swarthmore College February 23, 2016

Handling of Interrupts & Exceptions

CPEG421/621 Tutorial

OS Concepts and structure

CMSC 313 Lecture 12 [draft] How C functions pass parameters

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

Digital Forensics Lecture 3 - Reverse Engineering

CS Week 10. Lab Assignment 3 pt 3 and Project 3. Teaching Assistant Henrique Potter

Interrupts & System Calls

CS 318 Principles of Operating Systems

x86 architecture et similia

Function Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site)

Objectives. Making TOS preemptive Avoiding race conditions

CPSC 213. Introduction to Computer Systems. The Operating System. Unit 2e

X86 Stack Calling Function POV

Question 4.2 2: (Solution, p 5) Suppose that the HYMN CPU begins with the following in memory. addr data (translation) LOAD 11110

4) C = 96 * B 5) 1 and 3 only 6) 2 and 4 only

CMSC 313 Lecture 12. Project 3 Questions. How C functions pass parameters. UMBC, CMSC313, Richard Chang

CS 4284 Systems Capstone. Processes and Threads Godmar Back

6. Mechanism: Limited Direct Execution

Project 2: Signals. Consult the submit server for deadline date and time

CSE 153 Design of Operating Systems

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź

Processes. Chester Rebeiro IIT Madras

x86 assembly CS449 Fall 2017

Register Allocation, iii. Bringing in functions & using spilling & coalescing

The IA-32 Stack and Function Calls. CS4379/5375 Software Reverse Engineering Dr. Jaime C. Acosta

Overview REWARDS TIE HOWARD Summary CS 6V Data Structure Reverse Engineering. Zhiqiang Lin

CS 318 Principles of Operating Systems

Final exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Dec 20, Student's name: Student ID:

CSE 351: Week 4. Tom Bergan, TA

Buffer Overflow Attack

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19)

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING PREVIEW SLIDES 16, SPRING 2013

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27

This is a handout for source details that are would be impossible to read off a slide. Also, it should prove handy for later reference.

Overview. This Lecture. Interrupts and exceptions Source: ULK ch 4, ELDD ch1, ch2 & ch4. COSC440 Lecture 3: Interrupts 1

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING

Syscall Proxying. Simulating Remote Execution. Maximiliano Cáceres.

Tutorial 10 Protection Cont.

Program Exploitation Intro

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Shell Code For Beginners

Background: Operating Systems

Low-Level Essentials for Understanding Security Problems Aurélien Francillon

Intro to Threads. Two approaches to concurrency. Threaded multifinger: - Asynchronous I/O (lab) - Threads (today s lecture)

Machine-level Programming (3)

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

CS 550 Operating Systems Spring System Call

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

+ Overview. Projects: Developing an OS Kernel for x86. ! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT)

Instruction Set Architecture

The Geometry of Innocent Flesh on the Bone

System calls and assembler

W4118: virtual machines

Transcription:

COP4610: Operating Systems Project 1 Zhi Wang Florida State University Spring 2015 Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 1 / 8

Part 1: xv6 on QEMU Run xv6 ssh linprog.cs.fsu.edu wget http://www.cs.fsu.edu/ zwang/files/cop4610/ Spring2015/xv6_v8.tar.gz tar cd -xf xv6 v8.tar.gz xv6 to compile only: make to compile and run: make to quit qemu: ctrl-a x qemu-nox Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 2 / 8

User Space We use close as the example, read is similar. assuming a program calls close (5), 5 is an invalid file descriptor Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 3 / 8

User Space We use close as the example, read is similar. assuming a program calls close (5), 5 is an invalid file descriptor close is declared in user.h: int close(int); close is defined in usys.s: SYSCALL(close), which expands to.globl close; declare close as a global symbol close: definition of close movl $SYS close, %eax; put system call number in register eax int $T SYSCALL; trigger a software interrupt, enter the kernel ret return to the caller of close Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 3 / 8

User Space We use close as the example, read is similar. assuming a program calls close (5), 5 is an invalid file descriptor close is declared in user.h: int close(int); close is defined in usys.s: SYSCALL(close), which expands to.globl close; declare close as a global symbol close: definition of close movl $SYS close, %eax; put system call number in register eax int $T SYSCALL; trigger a software interrupt, enter the kernel ret return to the caller of close T SYSCALL defined in traps.h, SYS close defined in syscall.h Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 3 / 8

Entering the Kernel int $T SYSCALL triggers a software interrupt (T SYSCALL=64) CPU saves the current state, and calls the interrupt handler Interrupt handler for T SYSCALL is vector64 (vectors.s) vector64 jumps to alltraps function, which creates the trapframe, and calls trap (struct trapframe *tf) Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 4 / 8

Entering the Kernel int $T SYSCALL triggers a software interrupt (T SYSCALL=64) CPU saves the current state, and calls the interrupt handler Interrupt handler for T SYSCALL is vector64 (vectors.s) vector64 jumps to alltraps function, which creates the trapframe, and calls trap (struct trapframe *tf) struct trapframe saves the user-space registers. tf eax contains the system call number (SYS close) struct trapframe { uint edi; uint esi; uint ebp; uint oesp; uint ebx; uint edx;... Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 4 / 8

Syscall Dispatch trap (tf) calls syscall (void ) because (tf trapno == T SYSCALL) trapframe tf saved to the current process control block syscall reads the syscall number in eax, and calls sys close syscalls[sys close] return value is saved in tf eax, the kernel restores tf before returning to user space Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 5 / 8

sys close and Return sys close reads the parameter from user stack with argfd fd = 5, an invalid file descriptor sys close returns -1 it returns to syscall(void), which saves return value to eax and returns to trap trap returns to alltraps, which restores user registers and returns to user space with iret Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 6 / 8

Part 3: PS Define a New Syscall Hint: User space: declare getprocs in user.h, define getprocs in usys.s create a program called ps and add it to the makefile (refer cat.c) Kernel space: add a new system call number: SYS ps in syscall.h create the syscall handler (sys ps) in sysproc.c for SYS ps add sys ps to the syscall dispatcher syscalls follow close/sys close as an example to complete this part. Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 7 / 8

Part 3: PS sys ps proc.c has a global variable ptable with all the process control blocks sys ps copies each PCB to user-provided memory note: not all PCB states are copied check the size of the user-provided memory Zhi Wang (FSU) COP4610: Operating Systems Spring 2015 8 / 8