CSC209: Software Tools and Systems Programming. Richard Krueger Office hours: BA 3234

Similar documents
COURSE INTRODUCTION. Software Tools EECS2031 Winter 2018 Manos Papagelis. Thanks to Karen Reid and Alan J Rosenthal for material in these slides

CSC209 Fall Karen Reid 1

CSC209. Software Tools and Systems Programming.

CSC209. Software Tools and Systems Programming.

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

UNIX Kernel. UNIX History

Introduction to Linux

Introduction to Cygwin Operating Environment

Operating System Labs. Yuanbin Wu

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Welcome to Linux. Lecture 1.1

CS246 Spring14 Programming Paradigm Notes on Linux

Unix Handouts. Shantanu N Kulkarni

Overview of Unix / Linux operating systems

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

Perl and R Scripting for Biologists

EECS2301. Lab 1 Winter 2016

CSCI 2132 Software Development. Lecture 2: Introduction to UNIX and Unix-like Operating Systems

Operating System Labs. Yuanbin Wu

Introduction to Linux

Unix to Linux. CS 3113 Fall 2018 Dr. Christan Grant

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

UNIX Concepts COMPSCI 386

commandname flags arguments

Chapter-3. Introduction to Unix: Fundamental Commands

EL2310 Scientific Programming

The Operating System Machine Level

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Introduction of Linux. Huang Cheng-Chao Dept. of Comput. Sci. & Tech. East China Normal University

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Unix System Architecture, File System, and Shell Commands

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

UNIX File Hierarchy: Structure and Commands

Introduction to Linux

Arrays and Pointers. CSC209: Software Tools and Systems Programming (Winter 2019) Furkan Alaca & Paul Vrbik. University of Toronto Mississauga

Exploring the file system. Johan Montelius HT2016

The UNIX Time- Sharing System

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction to Linux

Files and Directories

h/w m/c Kernel shell Application s/w user

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

(a) About Unix. History

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Linux for Beginners. Windows users should download putty or bitvise:

EL2310 Scientific Programming

1 Installation (briefly)

CSCI 2132 Software Development. Lecture 4: Files and Directories

Unix/Linux: History and Philosophy

INF322 Operating Systems

Course and Unix Intro

NYU Poly s Policy on Academic Misconduct:

5/8/2012. Creating and Changing Directories Chapter 7

CS197U: A Hands on Introduction to Unix

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Getting started with Hugs on Linux

Lecture 01: welcome and intro what LSD and Unix have in common

Unix and C Program Development SEEM

CISC 220 fall 2011, set 1: Linux basics

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

Introduction to Unix: Fundamental Commands

Files

Getting started with Hugs on Linux

The Operating System Machine Level

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Operating Systems, Unix Files and Commands SEEM

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Unix Tools / Command Line

The UNIX File System

Security Architecture

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Underlying computer system = hardware + software

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

Topics. Operating System I. What is an Operating System? Let s Get Started! What is an Operating System? OS History.

Projects and Environment Introduction

UNIX / LINUX - GETTING STARTED

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?

Continue: How do I learn C? C Primer Continued (Makefiles, debugging, and more ) Last Time: A Simple(st) C Program 1-hello-world.c!

Reviewing gcc, make, gdb, and Linux Editors 1

The UNIX operating system is a set of programs that act as a link between the computer and the user.

UNIX rewritten using C (Dennis Ritchie) UNIX (v7) released (ancestor of most UNIXs).

by Pearson Education, Inc. All Rights Reserved.

Department of Computer Science and Technology

The Unix Shell & Shell Scripts

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

CSC UNIX System, Spring 2015

Basic File Attributes

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems

Midterm 1 1 /8 2 /9 3 /9 4 /12 5 /10. Faculty of Computer Science. Term: Fall 2018 (Sep4-Dec4) Student ID Information. Grade Table Question Score

COMP1917: Computing 1 1. Introduction

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Project 1 System Calls

Transcription:

CSC209: Software Tools and Systems Programming Richard Krueger Email : krueger@cs.utoronto.ca Office hours: BA 3234

Administrivia Email: krueger@cs.utoronto.ca Email must include your name. Please set up your mail program to use plain text, not HTML. Email is a formal method of communication: Use proper English. State your question clearly, with enough context. Sign it. 2

More on email Not helpful I used the makefile you gave us, but my program doesn t compile. What could be wrong? My program gets a seg fault error message, but I don t know why. Much better When I compile my program, I get the following error message. It seems to indicate that there is a problem with the following lines of code. (cut and paste error messages and code.) The debugger tells me that the seg fault I m getting is on the following line. I don t see what the problem is with this line. (file included below) 3

Course Information Check the course information sheet (handed out and on the course web page) for Office hours Contact information Assignment schedule The course web page is the official source of announcements. http://www.cs.utoronto.ca/~csc209h/ Make sure you have the prerequisites! 4

Assignments A1: Shell programming (Bourne shell) A2: Manipulating files and directories (in C) A3: Processes (in C) A4: Sockets (in C) The assignments are best done over a couple of weeks, a few hours at a time. All code must work on the CDF servers to receive full marks. Don t wait until the last day! 5

Submitting Assignments You will be using CVS to manage and submit your assignments. The repositories will be set up this week. You should start learning how to use it as soon as possible. Do not wait until the last minute to try to commit your assignment for the first time. First tutorial will cover using CVS. See web page for tutorial information. 6

Plagiarism The work you submit must be your own, done without participation by others. It is an academic offense to hand in anything written by someone else without acknowledgement. You are not helping your friend when you give him or her a copy of your assignment. You are hurting your friend when you ask him or her to give you a copy of their assignment. 7

What is cheating? Cheating is copying parts or all of another student s assignment including code from books, web sites, other courses without attribution getting someone else to do substantial parts of your assignment giving someone else your solution Cheating is not helping to find a bug in a friend s code (be careful) helping each other understand man pages or example code. 8

The Big Picture (in Java) Source code file Hw.java FODVV+Z^ SXEOLFVWDWLFYRLG PDLQ6WULQJ>@DUJV^ VRSULQWOQ+HOOR ` ` Compile it % javac Hw.java Object file Hw.class Run it in VM Process % java Hw 90 +Z 9

The Big Picture Source code file hw.c LQFOXGHVWGLRK! YRLG PDLQ ^ SULQWI+HOORZRUOG ` Compile it % gcc o hw hw.c hw Object file Run it Process % hw 10

Source Code Files hw.c LQFOXGHVWGLRK! YRLG PDLQ ^ SULQWI+HOORZRUOG ` What is a file? How does the system know where to find hw.c? What is the meaning of #include<stdio.h>? What does printf really do? 11

Compiling a program % gcc o hw hw.c A compiler is a program that translates source code into object (machine) code. Here we are running the compiler at the command line. A shell is a program that can execute another program. 12

Shells % gcc o hw hw.c The % is a shell prompt. Shells accept commands (programs) as input finds the executable interprets the arguments starts executing the command Shells also have some built-in commands. 13

Object Files/Executables stack high address Typical memory layout of programs. Process control block (PCB) sp (stack pointer) heap pc (program counter)... uninit. data init. data text low address 14

Running a program % gcc o hw hw.c % hw load a program into memory and hand it off to the OS to run the program. 15

Processes A process is an executing instance of a program. The OS keeps track of information about the process. process ID a unique non-negative integer process state running, ready, blocked program counter which instruction is being executed. a list of open files etc. 16

A different big picture sh less vi perl gcc nedit grep ddd libc C Interface to Unix system services Unix system services Unix kernel (in C) computer 17

Course Overview Software Tools Understanding the shell Shell programming Systems Programming C files processes concurrency communication 18

Self Study Topics Using CVS - some tutorial coverage Using Unix - some tutorial coverage Learning an editor nedit, vi, emacs Learning a debugger ddd is the easiest, gdb Readings 19

Unix History Inspired by Ken Thompson to play Space Travel on his DEC PDP-7 in 1969. Thompson wrote the first version of Unix in assembler in one month. Dennis Ritchie and Ken Thompson ported an enhanced version to a PDP-11/20 in 1970. Ritchie and Rudd Canaday ported a cut down version of the BCPL language to Unix, calling it B. The PDP-11 was purchased for text processing. The first user was Bell s Patent Department. Pipes and C were added in 1971-73 20

More Unix History BTL Lawyers, License to universities, but no support. This led to extensive sharing. University of Toronto on the first mailing list in 1975. Software Tools User Group formed in 1978. Canadian connection! Bill Reeves, Brian Kernighan, Rob Pike... Berkeley Software Distribution grew out of collecting and distributing bug fixes. (Led to FreeBSD, NetBSD) Bill Joy started at Berkeley but joined the startup Sun Microsystems in 1982. 1991, Linus Torvalds posts a note describing his experimental OS modeled on minix. 21

Why Unix? Available on a number of platforms. Multi-user, multi-programmed. Shares computer resources sensibly. Permits manipulation of files, processes, and programs. Allows inter-process and inter-machine communication. Permits access to its operating features. 22

The Unix Philosophy Write programs that do one thing and do it well. Write programs to work together. Write programs that handle text streams, because that is a universal interface. 23

Files and Directories Everything is a file. Unix provides a file interface for all Input/Output. regular files directories devices video (block) keyboard (character) sound (audio) network (block) File interface = open, read, write, close Try ls l /dev and look at the permissions string. crw------- brw------- c = character, b = block 24

File System Hierarchy Everything starts in the root directory whose name is / A directory is a file that contains directory entries. (Ch 4.3) A directory entry maps a file name to an inode. An inode is the data structure that contains information about a file, including which disk blocks contain the file data. 25

File System Hierarchy / hard link u h usr u1 u2 u3 bin lib symbolic links krueger csc209h IDOO SXE F c4reidka Use df to see all the different disk partitions on CDF. UHSR 26

File Systems and Links One file system per disk partition. A file system can be mounted at any point in the directory tree of another file system. An entry in a directory file which specifies an inode is a hard link. There can be several hard links to a file, but hard links cannot cross file systems. A soft link (symbolic link) is a small file containing the path name of the linked file or directory. Soft links work across file systems. Ch. 4.5, 4.3, 3.2 27

Directories and Links GLUHFWRU\ILOH 2. 2.. 14 u 46505 home 139412 cdrom 201345 lib % ls l / drwxr-xr-x 2 root root 4096 Nov 8 17:56 bin/ drwxr-xr-x 2 root root 4096 Aug 10 14:46 cdrom/ drwxrwsr-x 2 root staff 4096 Feb 8 2002 home/ drwxr-xr-x 6 root root 4096 Sep 2 15:26 lib/ lrwx------ 1 root root 6 Sep 2 15:32 u -> /cdf/u/ 28

Inodes and Directory Entries Directory Entry 12345 afile 12345 Inode size owner UID, GID access time modified time creation time link and block counts permissions direct pointers to file blocks single indirect pointer double indirect pointer triple indirect pointer pointers to next file blocks 29

Stat &K eddie% stat csc209h File: "csc209h" Size: 3584 Allocated Blocks: 8 Filetype: Directory Mode: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 517/ csc209h) Device: 0/6 Inode: 1055265 Links: 143 Device type: 0/0 Access: Sun Aug 26 15:00:58 2001 Modify: Mon Jul 23 09:26:51 2001 Change: Mon Jul 23 09:26:51 2001 man 2 stat shows the C function 30

&K Permissions UZ[U[U[ UHLG -DQ DOOH[HF UZUU UHLG -DQ DOOUHDG UZ UHLG -DQ RZQHUUHDG UUU UHLG -DQ UHDGRQO\ GUZ[U[U[ UHLG -DQ GLUUHDG GUZ[[[ UHLG -DQ GLUVHDUFK user group UZ[U[U[ File permissions read, write, execute pretty much what you think Directory permissions read you can run ls on the directory write you can create and delete files in the directory execute you can pass through the directory when searching subdirectories. other 31

Example UUU UHLG -DQ UHDGRQO\ GU[U[U[ UHLG -DQ GLUUHDG G[[[ 1 reid 0 Jan 11 22:23 dir-search ---x--x--x 1 reid 0 Jan 11 22:23 dir-search/xfile What is the result of the following: $ ls read-only $ read-only $ ls dir-search $ dir-search/xfile $ cd dir-search Use chmod to change file permssions. 32