CSE 451 Section #3 Project 0 Recap Project 1 Overview

Slides:



Advertisements
Similar presentations
CSE 451: Operating Systems Section 3 Project 0 recap, Project 1.
Advertisements

CSE 451: Operating Systems Section 2 Shells and System Calls.
1 Processes Professor Jennifer Rexford
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
1 CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 1-2, Thu 4:30-5:30 Allen 218 (or lab)
CSE 451 Section Autumn 2005 Richard Dunn Office hours: WTh 3:30-4:20 Allen 216 (or lab)
CS-502 Fall 2006Project 1, Fork1 Programming Project 1 – Fork.
Project 1CS-3013 A-term Programming Project #1 Forking Processes Due Tuesday, September 8, 11:59 PM.
OS Spring’03 Introduction Operating Systems Spring 2003.
CSE 451: Operating Systems Section 2 Interrupts, Syscalls, Virtual Machines, and Project 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
System Calls 1.
Project 1, Command Shell CS-502 (EMC) Fall Programming Project #1 Command Shell CS-502, Operating Systems EMC, Fall 2009 (Slides include materials.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
Chapter 2: Linux & POSIX “She sells bash shells by the C shore”
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview Part 2: History (continued)
CSE 451 – Operating Systems Section, Autumn 2003 TAs: Mike Swift Adrienne Noble
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
CS 346 – Chapter 2 OS services –OS user interface –System calls –System programs How to make an OS –Implementation –Structure –Virtual machines Commitment.
CSE 451: Operating Systems Section 3: Project 0 recap, Project 1.
Operating Systems Process Creation
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
CSE451 Section 2: Spring 2006 Kurtis Heimerl, YongChul Kwon
OS Labs 2/25/08 Frans Kaashoek MIT
1 CSE 451 Section 2: Processes, the shell, and system calls.
CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 2-3, Thu 4:30-5:30 Allen 216 (or lab)
1 Intro to the Shell with Fork, Exec, Wait Sarah Diesburg Operating Systems CS 3430.
Introduction to Operating Systems Concepts
Implementation of a simple shell, xssh
Exceptional Control Flow
Topic 2: Hardware and Software
Unix Basics.
Introduction to Operating Systems
Processes and threads.
Implementation of a simple shell, xssh (Section 1 version)
CSE 451 Section 2: Processes, the shell, and system calls
Implementation of a simple shell, xssh
Chapter 2: System Structures
UNIX System Overview.
CS 3305 System Calls Lecture 7.
Operating Systems: A Modern Perspective, Chapter 6
Operating Systems Georgios Varsamopoulos
The Linux Operating System
Introduction to Operating System (OS)
CSE 303 Concepts and Tools for Software Development
KERNEL ARCHITECTURE.
Operation System Program 4
Introduction to Operating Systems
CSE 390a Lecture 1 introduction to Linux/Unix environment
2/25/08 Frans Kaashoek MIT OS abstractions 2/25/08 Frans Kaashoek MIT
Process Programming Interface
Programming Project #1 Command Shell
CSE 451 Section 2 – Winter 2006.
Programming Project #1 Fork and Command Shell
CSE 451 Section 2 - Spring 2005.
Linux Shell Script Programming
Implementing Processes, Threads, and Resources
introduction to Linux/Unix environment
Operating System Concepts
Operating System Concepts
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

CSE 451 Section #3 Project 0 Recap Project 1 Overview Shells & System Calls Sean's awesome examples

Project 0 Part 1: Mean = 1.59 Median = 2 Part 2: Mean = 1.32

Project 0 Part 1 Problems Sort didn't work Need to test on more than 4 values! Need non-deterministic tests! Failed to free(oldHead) Memory leak... Free after last access to variable

Project 0 Part 2 Problem #1 Comparing key pointers directly key == ht[loc].key Not OK in general, or for this project! hash_func(key) == hash_func(ht[loc].key) OK for this project, but not OK in general equals_func(key, ht[loc].key) Best solution, not required for this class

Project 0 Part 2 Problem #2 Linear probing misunderstandings If using linear probing, you MUST mark a cell as vacated, which is different than free Consider hash table size of 10 Insert key1, hash = 5 & Insert key2, hash = 15 Occupy positions 5 & 6 Delete key1 Lookup key2 – 5 is empty but need to look at six also

Project 1 Your first Operating System project. Goals: To understand the relationship between shells, system calls, and the kernel To become familiar with the tools and skills needed to understand, modify, compile, install, and debug the Linux kernel To design and implement an extremely simple shell and system call

Project 1 Teaches you: how to handle processes how to build & run Linux in VMware Two main parts: Write a simple shell in C Add a simple system call to Linux kernel Due: Friday, April 24, 2009 at 11:59pm Electronic turnin: code + writeup Dust off C skills Become familiar with the environment we use

The shell What is it?

The shell “A program that works with the operating system as a command processor, used to enter commands and initiate their execution.” -- American Heritage ® Dictionary of the English Language Examples of shells: UNIX: bash, csh, … Windows: command prompt

The UNIX shell Internal (built-in) commands Execute routines embedded in the shell Manage state of the shell (e.g., current working directory, environment variables) Examples? External commands How can you tell external from internal? Internal commands: cd, export, for, if, time, … External commands: ls, rm, …

Other UNIX shell capabilities Redirect stdin / stdout / stderr # ./my_parser < logfile > outfile 2> errfile Background execution of process # ./my_parser < logfile > outfile 2> errfile & Command pipelines # ps –ef | grep java | awk ‘{print $2}’

The CSE451 shell Print out prompt Accept input Parse input If built-in command do it directly Else spawn new process Launch specified program Wait for it to finish Repeat CSE451Shell% /bin/date Fri Jan 16 00:05:39 PST 2004 CSE451Shell% pwd /root CSE451Shell% cd / / CSE451Shell% exit Actually, also special built-in commands which do not fork off a process. E.g.: cd, exit, new syscall execcounts.

CSE451 Shell Hints In your shell: Use fork to create a child process Use execvp to execute a specified program Use wait to wait until child process terminates Useful library functions (see man pages): Strings: strcmp, strncpy, strtok, atoi I/O: fgets Error report: perror Environment variables: getenv

System Calls What’s a system call? Examples? How do system calls compare to library calls? a system call is the mechanism used by an application program to request service from the operating system. System calls often use a special machine code instruction which causes the processor to change mode (e.g. to "supervisor mode" or "protected mode"). This allows the OS to perform restricted actions such as accessing hardware devices or the memory management unit.

System calls & library calls Using some OS service Process/Signal/File/Network/IPC/… Library call Not using any OS service Provide a high level interface for OS service What happens when we call strncpy(3) ? fgets(3) ? Draw picture w/ OS, system call interface, libraries and their interfaces, and apps

Project 1: Adding a System Call Add execcounts system call to Linux: Purpose: collect statistics Count number of times you call fork, vfork, clone, and exec system calls. Steps: Modify kernel to keep track of this information Add execcounts to return the counts to the user Use execcounts in your shell to get this data from kernel and print it out.

Example of execcounts CSE451Shell% execcounts clear CSE451Shell% cd / CSE451Shell% pwd / CSE451Shell% date Wed Sep 29 16:52:41 PDT 2004 CSE451Shell% time Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose] […] CSE451Shell% execcounts Statistics: Fork: 3 27% Clone: 0 0% VFork: 0 0% Exec: 8 72% CSE451Shell% exit

Programming in kernel mode Your shell will operate in user mode Your system call code will be in the Linux kernel, which operates in kernel mode Be careful - different programming rules, conventions, etc.

Programming in kernel mode Can’t use application libraries (e.g. libc) E.g. can’t use printf Use only functions defined by the kernel E.g. use printk instead Include files are different in the kernel Don’t forget you’re in kernel space You cannot trust user space E.g. unsafe to access a pointer from user space directly As a programmer, you know that an application can call functions it doesn't define: the linking stage resolves external references using the appropriate library of functions. printf is one of those callable functions and is defined in libc. In the kernel, the only functions you can call are the ones exported by the kernel; there are no libraries to link to. The printk function, for example, is the version of printf defined within the kernel and exported to modules. It behaves similarly to the original function, with a few minor differences, the main one being lack of floating- point support.[6]

Kernel development hints Best way to learn: read existing code Use grep –r search_string * Use LXR (Linux Cross Reference): http://lxr.linux.no/

Computing Resources Develop your code on forkbomb Test your code on VMware PCs in 006 Do not use attu

VMWare Software simulation of x86 architecture Run an OS in a sandbox Easily reset to known good state

Using VMWare All disks are nonpersistent Power on/off, reset VMWare config Don’t change! All disks are nonpersistent Powering off loses your changes! Use “shutdown –r now” instead

Linux & VMware There is only one user: root (password: rootpassword ) You will need to: Build a kernel image on forkbomb Transfer it to Linux running inside VMware (you can use scp from the hosting OS) Boot your new Linux kernel in VMware Instructions at: http://www.cs.washington.edu/education/courses/451/09sp/projinfo.html