CSCI 2400/ ECE 3217: Computer Architecture

Slides:



Advertisements
Similar presentations
Client-server practices DSC340 Mike Pangburn. Agenda Overview of client-server development Editing on client (e.g., Notepad) or directly on server (e.g.,
Advertisements

Linux, it's not Windows A short introduction to the sub-department's computer systems Gareth Thomas.
CSCI 1411 FUNDAMENTALS OF COMPUTING LAB Lab Introduction 1 Shane Transue MSCS.
COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez
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.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
ENGINEERING COMPUTING CENTER LINUX workshop
A crash course in njit’s Afs
Unix Background / History CSE 4251, Sp 2014, Bolz 422 Dr. Bob Mathis,
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
1 Intro to Linux - getting around HPC systems Himanshu Chhetri.
Intro to Linux/Unix (user commands) Box. What is Linux? Open Source Operating system Developed by Linus Trovaldsa the U. of Helsinki in Finland since.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
Introduction to Linux ( I ) Sidney Fong 4 th Feb 2006.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
CS 590 Programming Environments with UNIX. Computer Lab Account Course Homepage
Getting started: Basics Outline: I.Connecting to cluster: ssh II.Connecting outside UCF firewall: VPN client III.Introduction to Linux IV.Intoduction to.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
CGS 3460 Why we choose UNIX n Powerful lMulti-user operating system lGood programming tools Most heavy-duty database management systems started out on.
CS2204: Introduction to Unix January 19 th, 2004 Class Meeting 1 * Notes adapted by Christian Allgood from previous work by other members of the CS faculty.
Linux and Java Basics. What is Linux? Operating system by Linus Torvalds that was a clone of Unix (thus Linux) Free and open source – this is the reason.
C By Example 1 The assumption is that you know Java and need to extend that knowledge so you can program in C. 1. Hello world 2. declarations 3. pass by.
City Cluster Quickstart Lien-Chi Lai, COLA Lab, Department of Mathematics, NTU 2010/05/11.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
Unix Servers Used in This Class  Two Unix servers set up in CS department will be used for some programming projects  Machine name: eustis.eecs.ucf.edu.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Intro to GNU/Linux See, Stallman? I said GNU. Are you happy now?
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Review Why do we use protection levels? Why do we use constructors?
Tutorial Six Linux Basics CompSci Semester Two 2016.
Overview of Linux Fall 2016 Dr. Donghyun Kim
Precept I : Lab Environment, Unix, Bash, Emacs
ENEE150 Discussion 01 Section 0101 Adam Wang.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Class Projects and Environment
SEEM3460 Tutorial Unix Introduction.
EE516: Embedded Software Project 1
UMBC CMSC 104 – Section 01, Fall 2016
CS1010: Intro Workshop.
The Machine Model Memory
Computer Science 210 Computer Organization
Tutorial Six Recap & Linux Basics CompSci Semester Two 2016.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Welcome to Linux Chap#1 Hanin Abdulrahman.
A bit of C programming Lecture 3 Uli Raich.
COSC 350 System Programming
Software Tools Recitation 1
Intro to UNIX System and Homework 1
Unit# 8: Introduction to Computer Programming
Computer Science 210 Computer Organization
C Programming Lecture Series
Govt. Polytechnic,Dhangar
Introduction to C Topics Compilation Using the gcc Compiler
Introduction Paul Flynn
Class Projects and Environment
Introduction to C Topics Compilation Using the gcc Compiler
Linux Professor Sabol.
Yung-Hsiang Lu Purdue University
Welcome to Linux Chap#1 Hanin Abdulrahman.
Video Notes.
Welcome to Linux Chap#1.
Presentation transcript:

CSCI 2400/ ECE 3217: Computer Architecture Saint Louis University Intro to Linux and C CSCI 2400/ ECE 3217: Computer Architecture Instructors: David Ferry

Saint Louis University Overview Linux C Hello program in C Compiling

History of Linux Way back in the day: Bell Labs Unix Saint Louis University History of Linux Way back in the day: Bell Labs Unix Widely available to students and instructors Very machine-independent Some direct Unix branches (e.g. Berkeley Unix or BSD) Others were inspired by Unix Minix- by Andrew S. Tannenbaum, an educational micro kernel Could re-implement the high-level design of Unix (e.g. Minix was originally system-call compatible with Unix) Linus Torvalds saw Minix and wanted to do his own version Wrote basic kernel from scratch Borrowed good ideas from Minix Included early support for GNU project software Completely free OS and system software

Linux Today Very small usage in desktop/laptop market (~3% in US) Saint Louis University Linux Today Very small usage in desktop/laptop market (~3% in US) Android is the biggest OS in mobile computing (~53% of US) Up to 85% of devices worldwide Linux drives internet servers (~97% of public servers) Linux drives supercomputing (~99% of TOP500 computers)

Getting Started with Linux at SLU Saint Louis University Getting Started with Linux at SLU Linux classroom and Linux lab on 1st floor Ritter Department Linux server: hopper.slu.edu Should use same username as SLU, but different password Talk to Dennis about password issues (office adjacent to lab) Recommended: Login to hopper.slu.edu via ssh Suggested: Work on local machine in lab Suggested: Login to hopper.slu.edu via NoMachine You may work however you like, but I can’t support other methods (e.g. Linux in a virtual machine on your laptop)

Logging in via SSH From OSX – can use terminal directly Saint Louis University Logging in via SSH From OSX – can use terminal directly Can transfer files with ‘scp’ command From Windows – can use an ssh client My favorite: Secure Shell extension for Chrome browser Plenty of others, just search for them Transfer files via WinSCP Username: your SLU username Hostname: hopper.slu.edu Via terminal: ssh dferry@hopper.slu.edu

Using the command line Enter one command per line Saint Louis University Using the command line Enter one command per line Lots of programs to accomplish what you want to do Just search “How do I accomplish XYZ in Linux terminal?” Useful commands: Command Description ls Lists contents of current directory ls -l Lists contents in list format cd Change current directory mkdir Make a new directory rm Remove a file rm -r Remove a directory cp file1 file2 Copies file1 to file2 cat file Prints file to the terminal wget url Downloads url to the current directory

Editing Text Files Text files- very important! Saint Louis University Editing Text Files Text files- very important! C programs for this class Very efficient storage for data and configuration Classic editors: vi and emacs Hard to get started initially Way faster once you get the hang of it Designed for low-bandwidth, spotty connections (think phone modems) Definitely worth it Other editors: Text editors- search them! GUI editors- search them!

For next time: Find a good Linux environment you’d like to use Saint Louis University For next time: Find a good Linux environment you’d like to use Try logging into hopper.slu.edu Next homework involves writing C code

Saint Louis University Overview Linux C Hello program in C Compiling

The C Language Developed at Bell Labs to write Unix Saint Louis University The C Language Developed at Bell Labs to write Unix Practical language for practical projects Most OSes are written mostly in C (some assembly code) Most system libraries and tools are written entirely in C Small, simple language Easy to learn (especially at the time) Easy to port to different platforms Designed to replace Assembly Language Provides low-level access to memory Most operations map closely to assembly language operations Strongly typed, static type checking int, unsigned, float, double, char, etc. No runtime protection

Type Checking in C Several primitive types: Saint Louis University Type Checking in C Several primitive types: int, unsigned, float, double, char, etc. The compiler will not warn about possibly unsafe operations: int a; unsigned b; b = a; Correctness is up to the programmer! This kind of stuff is usually a bad idea though…

Command Line Input in C The main() function has two arguments: argc is the number of arguments argv is a vector of strings that hold those arguments E.g.: printing all values as strings int main ( int argc, char* argv[] ){ for( i = 0; i < argc; i++ ){ printf(“%s\n”, argv[i]); }

Converting Strings to Numbers How to convert “42” into the numeric value 42? atoi() Fast, easy, but dirty No safety or type checking Undefined behavior on overflow scanf() Works with floats and other data types strtol() Robust error checking, industrial grade

Manual Pages! (A.K.A. man pages) All of C (and much more beside) is documented in the manual pages, use them! At the command prompt: man man – manual for the manual pages() man atoi – manual for the function atoi() man scanf – manual page for the function scanf() Sometimes there are collisions: man printf – manual page for the bash command printf man 3 printf – manual page for the C function printf() man man – shows man page sections

(cond) ? (exec if true ) : (exec if false) Saint Louis University C Operators Usual arithmetic operators: Logical Operators: +, -, *, %, /, = && - logical AND || - logical OR ! - logical NOT Bitwise operators: & - AND Relational Operators | - OR == - True if equal ^ - XOR != - True if not equal ~ - complement < - True if less than << - left shift > - True if greater than >> - right shift <= - True if less or equal >= - True if greater or equal Ternary operator: (cond) ? (exec if true ) : (exec if false)

Hello, world! in C #include <stdio.h> int main( int argc, char* argv[] ){ int var = 42; printf(“Hello, world!\n”); printf(“Value of var: %d\n”, var); return 0; }

Compiling C programs We will use the gcc compiler If you have a program named prog.c: gcc -Wall -o prog prog.c -Wall turns on all warnings -o <name> output file name (default is a.out) Program files are listed by themselves Order isn’t important