01-intro_sol

38
Marco Caccamo & Wade Fagen Copyright ©: University of Illinois CS 241 Staff 1 Welcome to CS 241 Systems Programming at Illinois

Upload: crimsonredmk2

Post on 30-Oct-2014

15 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 01-intro_sol

Marco Caccamo & Wade Fagen

Copyright ©: University of Illinois CS 241 Staff 1

Welcome to CS 241 Systems Programming at Illinois

Page 2: 01-intro_sol

The Team

n  Marco Caccamo ¡  Office: 4118 SC (office hours:Monday,Friday 11.50-12.50)

n  Wade Fagen ¡  Office: 4101 SC (office hours TBA)

n  TAs ¡  Renato Mancuso, Paul Bissonnette, Vishnu Nath

Kamalnath, Giang Nguyen, Heechul Yun n  Discussion Sections

¡  8 sessions (Thursdays 9, 10, 12, 1, 2, 3, 4, 5) ¡  All sections in SC 0220

Copyright ©: University of Illinois CS 241 Staff 2

Page 3: 01-intro_sol

News and Email

n  Announcements and discussions: Piazza ¡  http://www.piazza.com/illinois/cs241

n  All class questions n  This is your one-stop help-line! n  Will get answer < 24 hours n  Access code is required! A link to the code on the course

website.

n  e-mail ¡  [email protected] ¡  Personal questions not postable on the news group

Copyright ©: University of Illinois CS 241 Staff 3

Page 4: 01-intro_sol

The Textbook (optional)

n  Introduction to Systems Concepts and Systems Programming ¡  University of Illinois Custom Edition ¡  Copyright © 2007 ¡  Pearson Custom Publishing ¡  ISBN 0-536-48928-9

n  Taken from: ¡  Operating Systems: Internals and Design Principles, Fifth Edition, by

William Stallings ¡  UNIX™ Systems Programming: Communication, Concurrency, and

Threads, by Kay A. Robbins and Steven Robbins ¡  Computer Systems: A Programmer's Perspective, by Randal E. Bryant

and David R. O'Hallaron

Copyright ©: University of Illinois CS 241 Staff 4

Page 5: 01-intro_sol

Your CS 241 “Mission”

n  Come to class ¡  MWF, 11-11:50am ¡  Please participate actively… ¡  Attend 1 discussion section per week

n  Study posted class lectures (textbook optional) ¡  Reading assignments posted on webpage

n  Homework (1) 3% n  Programming assignments (8) 47%

¡  Longer MPs are worth a little more

n  Midterm 20% ¡  Monday, March 4th 7:00pm – 9:00pm

n  Final 30% ¡  Monday, May 6th 7:00pm – 10:00pm

Copyright ©: University of Illinois CS 241 Staff 5

Page 6: 01-intro_sol

It’s all about the programming!

n  MPs ¡  Goal

n  Expose you to the concepts and APIs taught in class

¡  All individual n  You can’t learn it if

you don’t do it yourself!

n  MP Contest ¡  Memory (malloc) ¡  Prizes and bragging rights

n  Components for grading ¡  Correctness

n  Autograder n  Once a night to help you

check correctness n  Does not reflect grade

¡  Memory n  valgrind

¡  Debugging n  gdb

¡  Knowing your code n  1 page write-up (6 MPs) n  Oral description (1 MP)

Copyright ©: University of Illinois CS 241 Staff 6

Page 7: 01-intro_sol

Deadlines

n  Homework ¡  Deadlines are strict ¡  Late submissions will not be considered

n  MPs ¡  Please respect posted deadlines to ensure quick

grading ¡  Late MPs will be penalized 2% for each late hour

(rounded off to the higher hour) ¡  No submissions past 48 hours

Copyright ©: University of Illinois CS 241 Staff 7

Page 8: 01-intro_sol

Regrades

n  Considered if you were graded incorrectly

n  Within one week of posting of grades for a quiz, homework, MP or exam

n  Regrades must be submitted in writing on a separate piece of paper ¡  Please do not write on your homework,

MP or Exam

Copyright ©: University of Illinois CS 241 Staff 8

Page 9: 01-intro_sol

Academic Honesty

n  Your work in this class must be your own. n  If students are found to have cheated (e.g., by

copying or sharing answers during an examination or sharing code for the project), all involved will at a minimum receive grades of 0 for the first infraction and reported to the academic office.

n  Further infractions will result in failure in the course and/or recommendation for dismissal from the university.

n  Department honor code: https://wiki.engr.illinois.edu/display/undergradProg/Honor+Code

Copyright ©: University of Illinois CS 241 Staff 9

Page 10: 01-intro_sol

What is cheating in a programming class?

n  At a minimum ¡  Copying code ¡  Copying pseudo-code ¡  Copying flow charts

n  Consider ¡  Did some one else tell

you how to do it?

n  Does this mean I can’t help my friend? ¡  No, but don’t solve

their problems for them

n  Not cheating ¡  Discussing high-level

approaches ¡  Discussing MP

requirements, C language, tools

¡  Helping each other with debugging

Copyright ©: University of Illinois CS 241 Staff 10

Page 11: 01-intro_sol

Getting The Most Out Of Any Class

n  Get the big picture ¡  Why are we doing this? ¡  Why is it important?

n  Understand the basic principles ¡  If you know how to

apply them, you can work out the details

n  Learn why things work a certain way ¡  Automatic vs. manual,

elegant vs. ad hoc, solved problem vs. open

n  Think about the cost-benefit trade-offs ¡  Performance vs.

correctness, development time vs. benefit

Copyright ©: University of Illinois CS 241 Staff 11

Page 12: 01-intro_sol

Getting The Most Out Of This Class

n  Attend the lectures n  Pay attention to the discussions n  Ask questions, and participate n  Do the exercises in class n  Start the assignment the day it’s handed

out, not the day it’s due

Copyright ©: University of Illinois CS 241 Staff 12

Page 13: 01-intro_sol

What is systems programming?

Copyright ©: University of Illinois CS 241 Staff 13

Page 14: 01-intro_sol

What is systems programming?

sys·tem Noun /’sistəm/ 1. A set of connected things or parts forming a larger and more complex whole. 2. An integrated set of elements that accomplish a defined objective n Examples: Digestive system, economic system, ecosystem, social systems

n Computer systems: collections of programs ¡  Search engines, social networks, databases, Internet ¡  In this class, we learn how to design and implement

computer systems Copyright ©: University of Illinois CS 241 Staff 14

Page 15: 01-intro_sol

Challenges in programming computer systems

n  Sharing resources among programs n  Preventing malicious/incorrect

programs from interfering with other programs

n  Coordinating operations of multiple programs

n  Communicating information between programs

Copyright ©: University of Illinois CS 241 Staff 15

Page 16: 01-intro_sol

My Computer

What is an operating system and why do I need one?

n  What do we have? ¡  Set of common resources

Copyright ©: University of Illinois CS 241 Staff 16

Hardware Network

Page 17: 01-intro_sol

My Computer

What is an operating system and why do I need one?

n  What do we have? ¡  Set of common resources

n  What do we need?

Copyright ©: University of Illinois CS 241 Staff 17

Hardware Network

Page 18: 01-intro_sol

What is an operating system and why do I need one?

n  What do we have? ¡  Set of common resources

n  What do we need? ¡  A clean way to allow applications to use

these resources!

Copyright ©: University of Illinois CS 241 Staff 18

Hardware Network

Firefox Second Life Yahoo Chat GMail

Application Software

Page 19: 01-intro_sol

Application Requirements

Copyright ©: University of Illinois CS 241 Staff 19

Firefox

Application Software

Hardware Network

Rea

d/w

rite

Page 20: 01-intro_sol

Two Applications?

Copyright ©: University of Illinois CS 241 Staff 20

Firefox Second Life

Application Software

Hardware Network

Rea

d/w

rite

Dis

play

Page 21: 01-intro_sol

Managing More Applications?

Copyright ©: University of Illinois CS 241 Staff 21

Firefox Second Life Yahoo Chat

Application Software

Hardware Network

Dis

play

Rea

d/w

rite Stor

e

Page 22: 01-intro_sol

We need help!

Copyright ©: University of Illinois CS 241 Staff 22

Firefox Second Life Yahoo Chat GMail

Application Software

Hardware Network

Dis

play

Rea

d/w

rite Stor

e Send/receive

Page 23: 01-intro_sol

Approach: Find Common Functions

Copyright ©: University of Illinois CS 241 Staff 23

Firefox Second Life Yahoo Chat GMail

Application Software

Hardware Network

Dis

play

Stor

e Send/receive Rea

d/w

rite

Rea

d/w

rite

Page 24: 01-intro_sol

Delegate Common Functions

Copyright ©: University of Illinois CS 241 Staff 24

Firefox Second Life Yahoo Chat GMail

Application Software

Operating System

Network Hardware

Read/Write Standard Output

Device Control

File System Communication

Page 25: 01-intro_sol

Export a Standard Interface

Copyright ©: University of Illinois CS 241 Staff 25

Firefox Second Life Yahoo Chat GMail

Application Software

Operating System

Network Hardware

Read/Write Standard Output

Device Control

File System Communication

Standard Operating System Interface

Page 26: 01-intro_sol

Goal: Increase Portability

Copyright ©: University of Illinois CS 241 Staff 26

Firefox Second Life Yahoo Chat GMail

Application Software

Network Hardware

Read/Write Standard Output

Device Control

File System Communication

Operating System

Standard Operating System Interface

Machine Independent

Machine Specific

Page 27: 01-intro_sol

Machine Independent = Portable

Copyright ©: University of Illinois CS 241 Staff 27

Firefox Second Life Yahoo Chat GMail

Application Software

Read/Write Standard Output

Device Control

File System Communication

Operating System

Standard Operating System Interface

Port

able

Mac

hine

Inde

pend

ent

Page 28: 01-intro_sol

OS Runs on Multiple Platforms

Copyright ©: University of Illinois CS 241 Staff 28

Firefox Second Life Yahoo Chat GMail

Application Software

Network Hardware

Read/Write Standard Output

Device Control

File System Communication

Operating System

Standard Operating System Interface

Mac

hine

Inde

pend

ent

Mac

hine

Spe

cific

Page 29: 01-intro_sol

Mac

hine

Inde

pend

ent

Mac

hine

Spe

cific

OS Runs on Multiple Platforms

Copyright ©: University of Illinois CS 241 Staff 29

Firefox Second Life Yahoo Chat GMail

Application Software

Network Hardware

Read/Write Standard Output

Device Control

File System Communication

Operating System

Standard Operating System Interface

Same Interface!

Page 30: 01-intro_sol

POSIX The UNIX Interface Standard

Copyright ©: University of Illinois CS 241 Staff 30

Firefox Second Life Yahoo Chat GMail

Application Software

Read/Write Standard Output

Device Control

File System Communication

Unix

POSIX Standard Interface

Page 31: 01-intro_sol

Big goal: modularity

n  Modularity: Decomposition of a large task into smaller reusable components with well-known interfaces between them

n  Advantages ¡  Simplicity ¡  Portability ¡  Re-use common functions ¡  Abstraction: hide details of implementation

Copyright ©: University of Illinois CS 241 Staff 31

Page 32: 01-intro_sol

Course Questions

n  What are the right abstractions and interfaces to let pieces of a system work together smoothly?

n  …and how do I use them? n  What goes on “behind the scenes” in interfaces

I’ve been using? ¡  Memory, files, network, …

n  How do we tame the complexity of a big system? ¡  “Systems programming” is a lot more than just

programming!

Copyright ©: University of Illinois CS 241 Staff 32

Page 33: 01-intro_sol

Course Objectives

n  By the end of this course, you should be able to: ¡  Identify the basic components of an operating system ¡  Describe their purpose ¡  Explain the “black box” abstract interface and how they

function “inside the box”

n  Use the system effectively ¡  Write, compile, debug, and execute C programs ¡  Correctly use system interfaces provided by UNIX (or a

UNIX-like operating system)

n  Build your own large, multi-process, networked applications

Copyright ©: University of Illinois CS 241 Staff 33

Page 34: 01-intro_sol

Course Outline

n  Week 1-2: Nuts & bolts ¡  Manipulate pointers and memory ¡  Use UNIX system calls from within C programs ¡  MP1: working with C pointers & strings

n  Week 3-4: Memory ¡  Understand memory allocation and virtualization ¡  MP2: malloc (+contest!)

Copyright ©: University of Illinois CS 241 Staff 34

Page 35: 01-intro_sol

Course outline

n  Week 5-6: Parallelism ¡  Create and manage processes and threads ¡  Control scheduling of proc./threads ¡  MP3: Shell ¡  MP4: Multithreaded sorting ¡  MP5: Scheduling algorithm simulator

n  Week 7-11: Cooperating parallelism ¡  Communicating & sharing resources between

proc./threads ¡  MP6: Parallel make ¡  MP7: MapReduce

Copyright ©: University of Illinois CS 241 Staff 35

Page 36: 01-intro_sol

Course outline

n  Week 12-13: Networking ¡  Use communication protocols (TCP/IP) and

interfaces (Sockets) ¡  Write distributed multi-threaded apps that talk

across a network ¡  MP8: Web server (*)

n  Week 14: Additional OS concepts ¡  I/O and file systems

Copyright ©: University of Illinois CS 241 Staff 36

Page 37: 01-intro_sol

Complete Schedule

n  See class webpage http://courses.engr.illinois.edu/cs241/ ¡  Schedule is dynamic ¡  Check regularly for updates

n  Slides will be posted by the night before class ¡  Bring a print out of the slides to class ¡  Some class material may not be in slides

¡  Examples may be worked out in class

Copyright ©: University of Illinois CS 241 Staff 37

Page 38: 01-intro_sol

Your to-do List

n  Visit the class webpage ¡  Check out all the info

n  Especially schedule, grading policy, homework & MP hand-in instructions, and resources

n  Familiarize yourself with Piazza n  Find a reference to refresh your C

programming skills ¡  http://www.lysator.liu.se/c/bwk-tutor.html

Copyright ©: University of Illinois CS 241 Staff 38