CSE 451 Section Autumn 2005 Richard Dunn Office hours: WTh 3:30-4:20 Allen 216 (or lab)

Slides:



Advertisements
Similar presentations
1 Class motto: What’s this button for?. 2 CMSC104 Problem Solving and Computer Programming Fall 2011 Section 4 Richard Chang.
Advertisements

CSE 451: Operating Systems Section 2 Shells and System Calls.
1 Processes Professor Jennifer Rexford
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Introduction: C Pointers Day 2 These Slides NOT From Text.
1 CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 1-2, Thu 4:30-5:30 Allen 218 (or lab)
1 Reminders Project 1 due tomorrow by 6:00 Office hours in 006 today at 4:30 Start thinking about project groups (3 people) for the rest of the quarter.
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.
Course Introduction and Getting Started with C 1 USF - COP C for Engineers Summer 2008.
IntroductionCS-3013 C-term Programming Project #1 Forking Processes Due Thursday, January 24, 6:00 PM.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
CSE 451: Operating Systems Section 2 Interrupts, Syscalls, Virtual Machines, and Project 1.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
Project 1, Command Shell CS-502 (EMC) Fall Programming Project #1 Command Shell CS-502, Operating Systems EMC, Fall 2009 (Slides include materials.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Recitation 9: Error Handling, I/O, Man Andrew Faulring Section A 4 November 2002.
Natawut NupairojAssembly Language1 Unix Survival Guide.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
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”
CSE 451 – Operating Systems Section, Winter 2003 Scapegoats: Evan Welbourne Albert J. Wong
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.
Aug Introduction CMSC 104 section 301 Problem Solving and Computer Programming Fall 05.
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
Creating Programs on UNIX This term you can create programs on UNIX or you can create programs using a C++ compiler on your PC. This set of slides steps.
CSE 451: Operating Systems Section 3: Project 0 recap, Project 1.
Operating Systems Process Creation
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.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
Project 2: User Programs Abdelmounaam Rezgui Acknowledgment: The content of some slides is partly taken from Josh Wiseman’s presentation.
Recitation 9: Error Handling, I/O, Man Anubhav Gupta Section D.
CSE451 Section 2: Spring 2006 Kurtis Heimerl, YongChul Kwon
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
OS Labs 2/25/08 Frans Kaashoek MIT
1 CSE 451 Section 2: Processes, the shell, and system calls.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
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.
August 31, 2010Joris Geurts1 2IN05 Operating Systems Introduction to Linux More information for this course:
CSE 451 Section #3 Project 0 Recap Project 1 Overview
Error handling I/O Man pages
YongChul Kwon CSE451 Section 1: Spring 2006 YongChul Kwon
CS1010: Intro Workshop.
Introduction to Operating Systems
CSE 451 Section 2: Processes, the shell, and system calls
CSE 303 Concepts and Tools for Software Development
Computer Systems and Networks
Recitation: C Review TA’s 19 Feb 2018.
System Structure and Process Model
Lecture 5: Process Creation
Introduction to Operating Systems
System Structure and Process Model
Process Programming Interface
CSE451 Fall 2008 Section 1 Roxana Geambasu
Programming Project #1 Command Shell
CSE 451 Section 2 – Winter 2006.
System Calls David Ferry CSCI 3500 – Operating Systems
Tutorial: The Programming Interface
Programming Project #1 Fork and Command Shell
CSE 451 Section 2 - Spring 2005.
January 8, 2004 Adrienne Noble
Reminders Project 1 due tomorrow at 5:00 pm
EECE.4810/EECE.5730 Operating Systems
Intro to the Shell with Fork, Exec, Wait
Presentation transcript:

CSE 451 Section Autumn 2005 Richard Dunn Office hours: WTh 3:30-4:20 Allen 216 (or lab)

2 Reminders Sign up for mailing list Read the web site Work through lab information Start reading the book Do the first homework – due Monday! Check forkbomb access Read & start project 1

3 451 Projects 4 projects First one – individual, others – groups of 3 Need basic C and UNIX skills Check links if you need help with this Challenging Don’t leave until last minute Learn a lot of cool stuff

4 First Project Introduces C and Unix skills you’ll need Teaches how to build and run Linux in VMWare Two main parts: Write a simple shell in C Add a simple system call to Linux kernel Due: Friday, Oct 7, before lecture (2:30) Electronic turnin: code + writeup

5 The shell Print out prompt Accept input Parse input If built-in command do it directly Else create new process Launch specified program there Wait for it to finish Repeat CSE451Shell% /bin/date Fri Jan 16 00:05:39 PST 2004 CSE451Shell% pwd /root CSE451Shell% cd / CSE451Shell% pwd / CSE451Shell% exit

6 System Calls What’s a system call? Examples? 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

7 Project 1: Adding a System Call Add physusage system call to Linux: Purpose: count memory allocation Make a histogram of allocated memory sizes (powers of 2) Steps: Modify kernel to keep track of this information We give you the kernel code Add physusage to return the counts to the user Use physusage in your shell to get this data from kernel and print it out.

8 Example of physusage CSE451Shell% clear_physusage 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] [--portability] [--format=format] [--output=file] [-- version] [--help] command [arg...] CSE451Shell% physusage Total requests to page_alloc: 47 Requests for order 1 pages: 23 Requests for order 2 pages: 20 Requests for order 3 pages: 4 CSE451Shell% exit

9 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.

10 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 E.g. unsafe to access a pointer from user space directly, use fn’s that perform checks Best way to learn – look at existing code

11 Computing Resources Develop your code on dedicated 451 Linux host: forkbomb.cs.washington.edu Test your code on VMWare PCs in 006

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

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

14 Linux & VMWare There is only one user: root The password is rootpassword You will need to: Build a kernel image on forkbomb Transfer it to Linux running inside VMWare Boot your new Linux kernel in VMWare Use ftp to get your files into VMWare FTP to from the host running VMWare. E.g. using IE, go to

15 UNIX & C help Unix & C tutorial links on 451 projects page What if my shell crashes? Use gdb to debug gdb tutorials linked on web site What do I use to compile my shell? gcc. For example, gcc –o shell shell.c –Wall -g What do I use to type up my code? I recommend Emacs (look for Emacs tutorials) VS.NET works too

16 UNIX & C help - 2 How do I find stuff in the kernel source? Use grep –r search_string * Use LXR (Linux Cross Reference): Which library functions does C have to simplify my shell code? man strncmp, gets, fgets, strtok, strchr, perror

17 Refreshing C skills; code quality What’s wrong with this: char *buffer; buffer = malloc(100); strcpy(buffer, param); How do we fix this?

18 C Debugging hint #define MYDEBUG // comment out to disable debugging #ifdef MYDEBUG #define DEBUG(x) x #else #define DEBUG(x) #endif … int main() { … printf(“normal output”); DEBUG(printf(“debug output“)); … }

19 More debugging Just for printing: #ifdef MYDEBUG # ifdef __KERNEL__ /* This one if debugging is on, and kernel space */ # define PDEBUG(fmt, args...) printk(“myprg: " fmt, ## args) # else /* This one for user space */ # define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args) # endif #else # define PDEBUG(fmt, args...) /* not debugging: nothing */ #endif