1 CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 1-2, Thu 4:30-5:30 Allen 218 (or lab)

Slides:



Advertisements
Similar presentations
CSE 451: Operating Systems Section 2 Shells and System Calls.
Advertisements

1 Processes Professor Jennifer Rexford
Introduction: C Pointers Day 2 These Slides NOT From Text.
CSE 451 Section Autumn 2005 Richard Dunn Office hours: WTh 3:30-4:20 Allen 216 (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.
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.
Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
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.
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.
More on UART Interrupts; System Calls Reference on Interrupt Identification Register(IIR) slide 17 of
C Tutorial - Program Organization CS Introduction to Operating Systems.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
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.
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.
Process Management Azzam Mourad COEN 346.
Genesis: From Raw Hardware to Processes Andy Wang Operating Systems COP 4610 / CGS 5765.
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
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  There are many different.
OS Labs 2/25/08 Frans Kaashoek MIT
1 CSE 451 Section 2: Processes, the shell, and system calls.
Dsh: A Devil Shell COMPSCI210 Recitation 14 Sep 2012 Vamsi Thummala.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
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.
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
October 9 Section Mike Swift
Programming Project #1 Command Shell
CSE 451 Section 2 – Winter 2006.
Tutorial: The Programming Interface
Programming Project #1 Fork and Command Shell
CSE 451 Section 2 - Spring 2005.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
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:

1 CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 1-2, Thu 4:30-5:30 Allen 218 (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 tomorrow! Check spinlock/coredump 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, Jan 14, 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 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 We give you the kernel code Add execcounts to return the counts to the user Use execcounts in your shell to get this data from kernel and print it out.

8 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] [--portability] [--format=format] [--output=file] [-- version] [--help] command [arg...] CSE451Shell% execcounts Statistics: Fork: 3 27% Clone: 0 0% VFork: 0 0% Exec: 8 72% 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 hosts: spinlock, coredump Test your code on VMWare PCs in 006 Do not use attu

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 spinlock/coredump 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 works for both for kernel and userspace To use: PDEBUG(“Testing two numbers: %d and %d\n”, num, num2);