Last Week in Review - PowerPoint PPT Presentation

1 / 89
About This Presentation
Title:

Last Week in Review

Description:

UNIX - basic commands, man, ls, cd, pwd, passwd. flags. Buying or Upgrading ... How would you shop for a ... 1 kilobyte = 210 or 1024 bytes. 1 megabyte ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 90
Provided by: Her96
Category:
Tags: kilobyte | last | review | week

less

Transcript and Presenter's Notes

Title: Last Week in Review


1
Last Week in Review
  • Seneca Computer System
  • phobos
  • columbus - webpages
  • Operating Systems
  • function of the OS
  • UNIX - basic commands, man, ls, cd, pwd, passwd
  • flags

2
Buying or Upgrading Home Computer Systems
  • What would you look for in a home computer
    system?
  • How would you shop for a home computer system?
  • How would you go about upgrading your computer
    system?

3
Buying Terms
  • CPU - Central Processing Unit
  • MHz - Mega Hertz (speed)
  • RAM - Random Access memory
  • HARD DRIVE - GiG - Giga Bytes
  • CD ROM
  • MODEM

4
What would you look for in a home computer system?
  • What use will the machine go towards
  • word processing - letters, desk top publishing
  • accounting - spread sheets
  • games - heavy graphics usage
  • audio
  • ?

5
How would you shop for a home computer system?
  • Local Computer Store
  • Online
  • Large Computer Store
  • warranties
  • support - technically and instructionally
  • knowledge

6
How would you go about upgrading your computer
system?
  • Check the existing hardware configuration
  • Is there room to add RAM chips?
  • Can the motherboard support an upgraded chip?
  • Are there slots left if a peripheral expansion
    slot is required?
  • What is the pricing of upgrading versus a new
    complete system?

7
Generations of Computers
  • 1stbuilt with vacuum tubes
  • 2ndbuilt with transistors
  • 3rd built with integrated circuits
  • 4th built with a microprocessor
  • 5th built with intelligent computers

8
Classification of Computers
  • Supercomputer
  • Mainframe
  • Minicomputer
  • Workstation
  • Personal Computer
  • Notebook
  • Personal Digital Assistants
  • Network Computer

9
Computer Hardware
  • Physical parts of the computer system that you
    can see or touch.
  • Examples
  • Monitor / Keyboard / Mouse
  • CPU (Processor) / RAM / Main Board
  • Diskettes / Hard Disk / CD-ROMs
  • Modem / Printer / Scanner

10
Computer Software
  • Set of instructions (not easily seen or touched
    by humans) that control computer hardware and
    allow humans to interface and accomplish tasks
    with a computer system.
  • Categories of Software
  • System Software (Operating System)
  • Application Software (Word, Excel, etc...)

11
Functions of Computer Systems
  • Recall that there are four main functions of
    computer systems

Secondary Storage
Output
Input
Processing
12
Parts of the CPU
  • The CPU consists of a variety of parts including
  • Control unit
  • Arithmetic/logic unit (ALU)
  • Registers

13
Off/On Switches
  • The computer can represent data by constructing
    combinations of off or on switches.

or
off
on
14
Zero or One?
  • The binary system can also be represented by the
    digits zero and one.

0
1
or
Zero (off) and one (on) make up the two digits in
the binary system.
15
The Bit
one bit
  • Each 0 or 1 in the binary system is called a bit.

two bits
three bits
16
The Byte
  • A group of 8 bits is called a byte.

17
One Character of Data
  • Each byte represents one character of data (a
    letter, digit, or special character).

J

18
Storing Bytes
  • Storage and memory capacity is expressed in the
    number of bytes they can hold

1 kilobyte 210 or 1024 bytes 1 megabyte 220
or 1,048,576 bytes 1 gigabyte 230 or
1,073,741,824 bytes
19
Instruction Time
  • The time it takes to fetch an instruction and
    decode it is called instruction time.


20
Execution Time
  • The time it takes to execute an ALU operation and
    then store the result is called execution time.


21
Machine Cycle
  • The combination of I-time and E-time is called
    the machine cycle.

E- time
I- time
Machine Cycle
22
What is an Operating System
  • Control program for a computer
  • OS handles - communications between the
    application software and the computer hardware.
  • Memory protection - system accounting
  • smooth operation ? - Response Time

23
Last Week in Review
  • UNIX file structure - hierarchical (family tree
    analogy)
  • / - root directory - highest level
  • /home/ce124c your default directory - starting
    point. -
  • cd ltentergt will automatically take you to your
    home directory (default directory)

24
Directories
  • Inverted Tree Diagrams visualize directory
    structures

Root ( / )
home is theparent directory of ahersch
tmp
home
Ahersch
25
Last Week in Review
  • Connecting to the system
  • Seneca - telnet - phobos
  • Home - connect ISP - telnet//phobos.senecac.on.ca
  • hyperterminal in directly to the Seneca server
  • UNIX commands
  • ls , ls -a, ls -l, ls -al (ls -a-l)
  • passwd,
  • pwd, cd, man
  • control keys s,q,d,c,z, h, u,r,w

26
Agenda
  • Additional Unix Commands
  • Purpose of nled editor - screen editor
  • Using nled editor
  • Accessing/Exiting nled
  • Using nled help
  • Common nled commands
  • Using vi editor - screen editor
  • Compiling a Program - purpose and procedure
  • Printing Source Code / Check Print Status

27
Unix Commands
  • Unix is the operating system (OS) for your PHOBOS
    account.
  • Your PHOBOS account is currently configured as a
    Command-Driven Interface which means that you
    need to perform tasks by typing in a Unix command
    and pressing the ENTER Key.
  • Therefore,some knowledge of Unix operating system
    commands are required

28
Unix Commands
  • Directory Navigation Administration
  • pwd Displays current directory
  • cd /tmp Changes to tmp directory
  • cd Changes to your default directory
  • cd .. Changes to parent directory
  • mkdir name Creates directory called name
  • rmdir name Removes directory called name
  • rm -r name Removes a directory called name
  • with all files contained in that directory

29
Additional Unix Commands
  • File Navigation Administration
  • cat filename (Displays file contents)
  • more filename (Displays contents
    screenful at a time)
  • cat filename more (Displays contents - large
    files)
  • rm filename (Deletes file)
  • cp sourcefile destinationfile (Copies file)
  • mv oldfilename newfilename (Moves or renames
    file)
  • Note The symbol (ltSHIFTgtlt\gt) is used to
    combine Unix commands (pipe command)

30
Additional Unix Commands
  • Miscellaneous
  • clear Clears screen
  • who Displays users on server
  • whoami Identifies users logged onto server
  • finger user Displays various information of user
  • man Online Unix reference manual
  • passwd Change user password

31
Directories
  • Relative Directory Address
  • Directories relative to other directories
  • eg. cd ../tmp would mean to move back to parent
    directory and then forward to the tmp directory
  • Absolute Directory Address
  • Full directory path
  • eg cd /home/ahersch/tmp which would mean
    starting from root switch to the home directory
    then to the ahersch subdirectory then to the tmp
    directory within ahersch.

32
Wildcards
  • A wildcard character is used to represent any
    character. Useful when searching for files where
    the full name is not known.
  • ls file? (list all files with 1 character
    after file)
  • ls file?? (list all files with 2
    characters after file)

33
Wildcards
  • The character ? will match any single character.
    The character will match any number of
    characters
  • For Example
  • ls file (list all files in the current directory
    beginning with file)

34
Redirection
  • REMEMBER UNIX views all files and directories /
    input / output as files so
  • stdin - standard in - keyboard
  • stdout - standard out - screen.
  • A method to redirect output from screen display
    to a file is called redirection by UNIX.
  • E.g.. ls -al gt longlistroot.txt
  • will get a long listing of all
    files/directories in the current directory and
    rather than showing you on the screen will create
    the file longlistroot.txt and place the
    information in this file. (if it exists, it will
    destroy any information previously in the file)

35
Redirect Output to a File
  • Redirect to file - use gt
  • e.g. who gt who.txt
  • Note that redirecting a file will overwrite
    information on file if saved under the same
    filename.
  • NOTE if you do not want to overwrite use gtgt
    to append the information to the given file. As
    finger ahersch gtgt who.txt will add the finger
    information to the bottom of the who.txt file.

36
Pipe - FYI
  • A another useful feature of UNIX is its ability
    to combine one or more Unix commands
  • e.g..
  • ls -al more
  • This displays full listing of files, but pauses
    when screen becomes full.
  • This is a simplistic example and is for your
    information only. Pipe command is one of the most
    powerful features of UNIX.

37
Removing Directories
  • Removing directories is reverse order of building
    directories
  • Cannot remove directories containing files or
    other subdirectories
  • Need to step-back to at least parent directory
    to remove empty directory
  • Issue command rmdir

38
Directory / File Permissions
  • Because you share your account space on the
    PHOBOS server with other users, there is a
    concern that other users can modify or delete you
    directories or files in your account!
  • When you create a webpage on the COLUMBUS server,
    you should be aware of the same concerns!

39
File Permissions
40
Directory / File Permissions
  • There are 3 types of users that may be able to
    read / modify /execute your directories and files
  • Yourself (User)
  • Other users on your server (Group users)
  • Any Other User (i.e. Users viewing your webpage
    via their own Internet Service Provider)

41
Directory / File Permissions
  • Directory
  • d r w x r w x r w x
  • File
  • - r w x r w x r w x

User Group Other
User Group Other
42
Chmod Command
  • A Unix command to change the way in which a file
    (or directory) can be accessed by the owners of a
    file, the group to which the file belongs, and/or
    all other users

43
File Permissions Commands
  • chmod
  • u owner of the file
  • g group to which owner belongs
  • o all other users
  • a all users

44
File Permissions Commands
  • chmod
  • add permission
  • - remove permission
  • set permission
  • e.g.. Chmod uw,grw,or /home/ahersch/lab2

45
  • Purpose of a Text Editor
  • Editors
  • Line
  • Screen
  • In order to write programs, you need a text
    editor that can create a file. A text editor is
    also used to modify, print and save a file.
  • NLED - Neat Little Editor written by one of
    Senecas Computer Studies Faculty members.
  • vi - standard text editor available with Unix

46
Editors
  • There are two types of editors and two interfaces
  • Line and Screen Editors
  • Text and GUI interfaces

47
Editors
  • Ed and EDIT are LINE TEXT editors
  • NLED, VI and EMACS are SCREEN TEXT editors
  • WORD PERFECT, MS WORD, and WORD PRO are SCREEN
    GUI editors.

48
Note
  • nled is covered in our class notes
  • emac and vi are covered in many UNIX books.
  • emacs and vi are covered in UNIX SYSTEM V, Mark
    Sobell
  • ed, emacs and vi are covered in UNIX for DUMMIES,
    Levine and Young

49
Editors
  • Line editors are easy to use, but limited in
    scope
  • Screen editors are more complex, and more
    powerful.

50
Editors
  • Most people who program become VERY GOOD at one
    editor, usually a screen editor, and use that one
    editor all the time
  • Some people prefer the ease of a line editor, so
    they become VERY GOOD at one line editor, and
    competent with one screen editor

51
Line Editors
  • Line editors are easy to use, but limited in
    scope
  • few commands
  • can only edit one line at a time
  • limited cut and paste

52
Screen Editors
  • Screen editors are more complex, and more
    powerful.
  • Edits a full screen (24 lines) or more
  • Many commands
  • can cut and paste

53
Editors - Modes
  • Editors (both line and screen) have two modes
  • Insert Mode
  • Command Mode

54
Editors - What Mode am I in?
55
Editors - Insert Mode
  • The mode which allows you to add text to your
    document
  • usually, what you type becomes part of the
    document

56
Editors Enter Insert Mode
  • ED a or i
  • EDIT a or i
  • nled esc
  • emacs just type
  • vi a or i, A or I

57
Editors - Command Mode
  • The mode which allows you to perform tasks with
    your document such as add, delete, save.

58
EditorsEnter Command Mode
  • ed
  • edit
  • nled
  • emacs
  • vi
  • return on blank line
  • period alone on line
  • esc
  • uses control key for all commands
  • esc

59
EditorsHelp Commands
  • Ed none?
  • edit none?
  • nled ?
  • vi none?
  • emacs ? Or H

60
Creating a (Source) file - using nled
  • Logon to PHOBOS via telnet
  • At the Unix prompt type
  • nled file.name ltENTERgt

61
Nled Text Editor
  • There are 2 major modes or states for the
    Nled Editor
  • Input Mode (creating / moving / editing)
  • Command Mode
  • (execute commands - Help, Save, Print, etc)

62
Nled Text Editor
  • Movement
  • ltCTRLgtltdgt Move down one screenful
  • ltCTRLgtltugt Move up one screenful
  • ltCTRLgtltbgt Move to beginning of line
  • ltCTRLgtltegt Move to end of line
  • ltCTRLgtlttgt Move to top of file
  • ltCTRLgtltrgt Move to bottom of file

63
The Nled Text Editor
  • Common nled Commands
  • ltESCgtlt?gt Displays help menu
  • ltESCgtltbgt Mark beginning of block
  • ltESCgtltegt Mark end of block
  • ltESCgtltsgt Save file continue editing
  • ltESCgtltxgt Save file exit
  • ltESCgtltqgt Abandon recent edit exit

64
vi Editor - Basics
  • vi editor like nled is a text editor available
    to students to assist in creating source files
    for programs in the UNIX environment.
  • obscure and tedious initially to learn.
  • positives include available on most UNIX systems.
  • NOTE to use the vi editor your .profile must be
    changed so that the shell can locate the command.
  • Add following lines set -o vi

    EDITOR/usr/bin/vi
    export
    EDITOR

65
vi editor
  • There are 2 major modes or states of
    operation for the vi Editor
  • Input Mode (insert / append / enter mode)
  • Command Mode (delete characters, lines, movement
    / saving text / exiting).

66
vi editor - basics
  • MOVEMENT (command mode)
  • h move left one character
  • j move down one line
  • k move up one line
  • l move right one character
  • 0 move to beginning of current line
  • move to the end of the current line
  • b move up one screenful
  • f move down one screenful
  • G go to last line of file
  • 5G go to line 5 of the file.

67
vi editor - basics
  • Deletion (command mode)
  • x delete single character
  • dd delete current line
  • Save text / Exit (command mode)
  • w save the text with the original file name and
    continue editing
  • wq save text with the original file name and
    exit
  • q! Quit without saving any of the current
    changes.

68
vi editor - basics
  • Entering into Input mode
  • i input characters at the current cursor
    position
  • I input characters at the beginning of the line
  • a input characters to the right of the current
    cursor position
  • A input characters at the end of the current
    line
  • o input characters on a new line below the
    current line
  • O input characters on a new line above the
    current line.
  • NOTE Press the escape key to leave the input
    mode (return to command mode).

69
Compilers
70
Compilers
  • GAP between
  • how people think and how they solve problems
  • How computers are designed to solve problems

Selections from Fundamentals of Compilers by
Karen A. Lemone
71
Compilers
  • A compiler is a special translator which takes a
    high level language, such as Pascal or C, and
    translates it to a low level representation which
    the computer can ultimately execute

Selections from Fundamentals of Compilers by
Karen A. Lemone, page 2
72
Compilers
  • There are several compiler phases
  • Lexical analysis (scanning)
  • Syntactical analysis (parsing)
  • Semantic Analysis
  • Optimization
  • Preparation for code generation
  • Code Generation

Selections from Fundamentals of Compilers by
Karen A. Lemone
73
Compilers
  • TOKENS
  • A token is a lexical unit. For example
  • Keyword IF or PRINTF
  • A constant 3 or 133
  • Identifiers X or Name
  • operators , , or
  • Punctuation ( or

Selections from Fundamentals of Compilers by
Karen A. Lemone
74
Compilers
  • Lexical analysis (scanning)
  • Separates and groups characters into tokens. For
    example
  • X Y 12
  • would become
  • X,,Y,,12
  • for five tokens

Selections from Fundamentals of Compilers by
Karen A. Lemone
75
Compilers
  • Syntactical analysis (parsing)
  • Groups tokens into structures, for example
  • X Y 1
  • would be grouped as an assignment statement.

Selections from Fundamentals of Compilers by
Karen A. Lemone
76
Compilers
  • Semantic Analysis
  • Determines the meaning of phrases. For example
  • X Y 12
  • Does X and Y have a meaning?
  • Can 12 be added to Y?
  • Can this vale be assigned to X?

Selections from Fundamentals of Compilers by
Karen A. Lemone
77
Compilers
  • Optimization
  • Just what is says .. Can the code be run easier
    and/or faster

Selections from Fundamentals of Compilers by
Karen A. Lemone
78
Compilers
  • Preparation for code generation
  • What memory will be allocated
  • Which registers will be used

Selections from Fundamentals of Compilers by
Karen A. Lemone
79
Compilers
  • Code Generation
  • Generates ASSEMBLY / MACHINE language code for
    your program.

Selections from Fundamentals of Compilers by
Karen A. Lemone
80
Compilers
  • Example of Assembly code
  • PushAddr X
  • PushAddr Y
  • Load (S) R1
  • Load R2 12
  • Add R2 R1
  • Store R1 (S)

Selections from Fundamentals of Compilers by
Karen A. Lemone
81
Compilers
  • PushAddr X Find address for X, push
  • PushAddr Y Find address for Y, push
  • Load (S) R1 Load value of Y into R1
  • Load R2 12 Load number 12 into R2
  • Add R2 R1 Add R1 to R2, place in R2
  • Store R1 (S) Store value in R2 in X

Selections from Fundamentals of Compilers by
Karen A. Lemone
82
Compiling a Program
Edited File / Source Code
ExecutableFile
Compiler
hello.c
a.out
cc hello.c
83
Compiling a Program
  • Although there is more than one Unix command that
    may be used to compile a program, we will show
    you the cc Unix command. (C language compiler)
  • There are two different options of using the cc
    compiling command. One options creates an
    executable file called a.out, the other option
    allows the user to name the executable file.

84
Compilers
  • In UNIX, to compile a c program, you enter
  • cc hello.c
  • This creates an object module (hello.obj) which
    is then link/loaded with other system library
    programs to produce an executable file (also
    known as the Load module)(a.out). If errors arise
    you will receive some diagnostic messages.

Selections from Fundamentals of Compilers by
Karen A. Lemone
85
Compilers
  • See page 421 of the Capron textbook for a
    detailed description of the compiling
    process

86
Compilers
  • If you add a flag, -o the executable file will
    be renamed the new file name, e.g.
  • cc hello.c -o hello
  • this will create an executable file called
    hello (In some cases you will have to change
    the permissions allowing for execution (x) in
    order to run the file)

Selections from Fundamentals of Compilers by
Karen A. Lemone
87
Printing Source Code
  • At times you will require printouts of your C
    programming code here at Seneca.
  • To print your source code contained in a files
    say hello.c, type the following command at
    the prompt
  • lpr hello.c ltENTERgt
  • (NOTE Never send executable files or files that
    have been compiled to the printer!!! Certain
    codes can mess up the printers settings) The
    print out will be found in room 2115 (?)

88
Check Printing Status
  • Printouts are placed in order by a first-come,
    first printed out basis.
  • A program is used to line up the print jobs in a
    line (print queue) to be printed
  • If you want to see how many print-jobs are ahead
    of your own, you can check the status of your
    print-job by typing the following command at the
    Unix prompt
  • lpstat ltENTERgt (press ltCTRLgtltCgt to exit)

89
For next week
  • Read
  • Capron - Chapter 14 - Programming basics
  • Programming in C - Section 3 of the ICS124 NOTES
  • Complete Assignment 1 to be handed in beginning
    of class next week.
  • UNIX commands
Write a Comment
User Comments (0)
About PowerShow.com