1 CSE 451 Section 2: Processes, the shell, and system calls.

Slides:



Advertisements
Similar presentations
Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.
Advertisements

CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
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)
Linux+ Guide to Linux Certification, Second Edition
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.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Guide To UNIX Using Linux Third Edition
IntroductionCS-3013 C-term Programming Project #1 Forking Processes Due Thursday, January 24, 6:00 PM.
Systems Software Operating Systems.
CSE 451: Operating Systems Section 2 Interrupts, Syscalls, Virtual Machines, and Project 1.
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.
System Calls 1.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Simple Shell Part 1 Due date (75%): April, 2002 Part 2 Due date (25%): Apr 5, 2002.
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.
Linux+ Guide to Linux Certification, Third Edition
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.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
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)
Creating and Executing Processes
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.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
System calls for Process management
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.
CSI3131 – Lab 1 Observing Process Behaviour. Running Linux under Virtual PC  Start Virtual PC  This Windows program provides a virtual machine to run.
Operating Systems Process Creation
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
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.
Process Management Azzam Mourad COEN 346.
Homework Assignment #1 J. H. Wang Oct. 11, 2013.
Linux+ Guide to Linux Certification, Second Edition
CSE451 Section 2: Spring 2006 Kurtis Heimerl, YongChul Kwon
System calls for Process management Process creation, termination, waiting.
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.
CSE 451 Section #3 Project 0 Recap Project 1 Overview
Introduction to Operating Systems Concepts
Implementation of a simple shell, xssh
Navigating the Filing System
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
UNIX System Overview.
Operating Systems Georgios Varsamopoulos
The Linux Operating System
Shell Script Assignment 1.
CSE 303 Concepts and Tools for Software Development
System Structure and Process Model
System Structure B. Ramamurthy.
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
Intro to the Shell with Fork, Exec, Wait
Presentation transcript:

1 CSE 451 Section 2: Processes, the shell, and system calls

2 Homework 1 highlights (1.7.) Availability is typically ensured through replication (1.11.) Memory bus contention can occur (2.14.) User: Your arguments + VMs protect from compromised software (2.15.) Asynchronous communication: harder to program with, but does not interrupt.

3 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: Wed., Oct 15, 11:59pm Electronic turnin: code + writeup

4 Project groups Please form groups of 3 Send me s with groups by Tues., Oct. 7 After that, I will assign you to random groups You can change groups for next projects Only one person / group submits You can use CVS Instructions of how to set it up on forkbomb and use it are on website

5 The shell What is it?

6 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

7 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 Examples? How can you tell external from internal?

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

9 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% pwd / CSE451Shell% exit

10 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

11 System Calls What’s a system call? Examples? How do system calls compare to library calls?

12 System calls & library calls System call 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) ?

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

14 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

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

16 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

17 Kernel development hints Best way to learn: read existing code Use grep –r search_string * Use LXR (Linux Cross Reference):

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

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

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

21 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: /projinfo.htm