Programming Project 1 Fork - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Programming Project 1 Fork

Description:

Project 1, Fork. 3. Purpose. To practice using the fork and exec facilities of Unix/Linux ... find and use on-line documentation about system calls and system ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 14
Provided by: hughc7
Category:

less

Transcript and Presenter's Notes

Title: Programming Project 1 Fork


1
Programming Project 1 Fork
2
Programming Assignment
  • Write a command called doit to execute another
    command and print out statistics
  • Extend doit to become a basic shell that prompts
    for and executes commands
  • Extend your shell to shell2 to execute commands
    in the background

3
Purpose
  • To practice using the fork and exec facilities of
    Unix/Linux
  • To learn how to find and use on-line
    documentation about system calls and system
    facilities.
  • man pages
  • To be accustomed to speaking directly with the
    operating system

4
Part 1 doit
  • doit command
  • Take another command line as argument
  • Execute that command
  • Print out statistics about command
  • Must execute on a CCC or CS Linux system
  • May not use system() system call
  • Helpful hints
  • fork(), execvp(), wait()
  • getrusage(), gettimeofday()

5
Part 1 (output)
  • doit cat /etc/motd
  • / print the current message of the day /
  • / statistics about the cat command /

6
Part 2 shell
  • Repeatedly prompt for command lines
  • Execute each command and print out statistics, as
    in doit
  • Implement special built-in commands
  • exit
  • cd dir
  • Special conditions
  • Input from stdin
  • Exit on end of file
  • Complain about illegal commands
  • Check for line length, number of arguments

7
Part 2 output
  • shell
  • gtcat /etc/motd
  • / print the current message of the day /
  • / statistics about the cat command /
  • gtcd dir
  • / current directory is changed to dir /
  • gtls
  • / listing of files in current directory /
  • / statistics about this ls command /
  • gtexit
  • / back to your previous Linux prompt /

8
Part 3 Background execution (shell2)
  • Modify shell to support execute commands in
    background, indicated by character
  • Causes shell to prompt for next command before
    previous command is complete
  • jobs built-in command lists background tasks in
    progress
  • Report completion at next opportunity
  • E.g., the next time user types a command, but
    before executing that command

9
Part 3 output
  • shell2
  • gtnumbercrunch
  • 1 12345 / indicate background task 1,
    process id /
  • gtjobs
  • 1 12345 numbercrunch
  • / print process id and command name for tasks
    /
  • gtls
  • / listing of files in the current directory /
  • / statistics about this ls command /
  • gtcat /etc/motd
  • 1 12345 Completed lt background job command gt
  • / statistics about background job /
  • / print the current message of the day /
  • / statistics about this cat command /
  • gtexit
  • / back to your previous Linux prompt /

10
Work environment
  • You may do this work on
  • CCC machine
  • CS machine
  • Your virtual machine (if you have set it up
    already)
  • You may use C or C
  • Note
  • CCC and CS do not use same version of Linux
    kernel or C/C compiler
  • Your virtual machine uses the latest version

11
Project submission
  • Due Monday, September 25, at start of class
  • Submit via turnin
  • command /cs/bin/turnin on CCC machines
  • classname cs502
  • assignment project1
  • Put your name at top of every file!
  • (You would be surprised how many students forget!)

12
Project Submission (continued)
  • Code of your solution
  • Makefile to build all programs
  • One or more test cases
  • Write-up explaining everything
  • DO NOT
  • Put different parts of projects in folders
  • Create different Makefiles for different parts

13
Not a team project!
  • Each student must submit own solution
  • Encouraged to discuss general approach, meaning
    of system calls, etc., with friends
  • Encouraged to seek help if puzzled by some
    concept, system call, etc.
  • Distill all discussions into your own work!
Write a Comment
User Comments (0)
About PowerShow.com