Docsity

TCSS 422: Operating Systems - Introduction to Operating Systems and Resource Management, Study notes of Operating Systems

Toggle sidebar
bg1
TCSS 422 A – Spring 2017
Institute of Technology
3/28/2017
L1.1
Slides by Wes J. Lloyd
March 28, 2017 TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
INTRO DUC TIO N
Wes J. Lloyd
Institute of Tec hnology
Uni versity of Wa shing ton - Taco ma
TCSS 422: OPERATING SYSTEMS
Syl lab us, C our se I ntr oduc tion
Cha pte r 4: Ope rati ng S yste ms – Thr ee E asy P iece s
Intr oduc e oper ating syste ms
Man agemen t of r esour ces
Con cepts of vi rtual izati on/ab stract ion
CPU, Mem ory, I/O
Ope rati ng sys tem de sign goal s
March 28, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L1.2
OB JECTI VE S
Sy llab us
Gr adi ng
Sch edu le
As sig nme nts
March 28, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L1.3
TCS S422 – O PERAT IN G SYSTE MS
As sig nme nts
Ass ignme nt 0: Linu x war m-up
Ass ignme nts 1 -4: r ough ly eve ry t wo we eks
Qui zz es
~ 7- 8 qu izze s
Dro p low est tw o
Vari ety o f for mats : in c lass , onl ine, read ing, tutor ial ac tivi ty
Exa ms: Mid term an d Fi nal
Two p ages of n otes, calc ulato r
Fin al exa m is comp rehen sive
March 28, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L1.4
TCS42 2 COUR SE W OR K
Pro gr ams :
Ple ase st art earl y
Work as i f th ough t he de adli ne is 2 da ys ea rlie r
March 28, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L1.5
TCS S 4 22: P ROGR AM D UE DATES
From Virginia Tech Department of Computer Science -2011
Better than 50%
chance of A/B
Less than 50%
chance of A/B
Cen tOS 7
Ope n sou rce v ersi on of RedHa t (RH EL) Linux
Pac kage m anag ement : YUM repo sitor ies
Repo sito rie s of R PM ( RedH at Pa cka ge Fi les)
Cen tOS Adv ant ages
Ent erpri se Lin ux D istr ibuti on
Cen tOS i s equ ival ent to RHEL , a p opul ar co mmerc ial Li nux d istr o
Lear ning Cent OS (f ree) is a prox y for lear ning RHEL (not free )
Onl y sta ble v ersi ons of sof twar e pack ages fewe r cras hes & err ors
Few er rel ease s, mo re st able, ligh twei ght, f ast
March 28, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L1.6
CE NTO S 7 – VIRT UAL MACHINE
pf3
pf4
pf5

Partial preview of the text

Download TCSS 422: Operating Systems - Introduction to Operating Systems and Resource Management and more Study notes Operating Systems in PDF only on Docsity!

Institute of Technology

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma

INTRODUCTION

Wes J. Lloyd

Institute of Technology

University of Washington - Tacoma

TCSS 422: OPERATING SYSTEMS

 Syllabus, Course Introduction
 Chapter 4: Operating Systems – Three Easy Pieces
 Introduce operating systems
 Management of resources
 Concepts of virtualization/abstraction
 CPU, Memory, I/O
 Operating system design goals

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

OBJECTIVES

 Syllabus
 Grading
 Schedule
 Assignments

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

TCSS422 – OPERATING SYSTEMS

 Assignments
 Assignment 0: Linux warm-up
 Assignments 1-4: roughly every two weeks
 Quizzes
 ~ 7-8 quizzes
 Drop lowest two
 Variety of formats: in class, online, reading, tutorial activity
 Exams: Midterm and Final
 Two pages of notes, calculator
 Final exam is comprehensive

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

TCS422 COURSE WORK

 Programs:
 Please start early
 Work as if though the deadline is 2 days earlier

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

TCSS 422: PROGRAM DUE DATES

From Virginia Tech Department of Computer Science - 2011 Better than 50% chance of A/B Less than 50% chance of A/B

 CentOS 7
 Open source version of RedHat (RHEL) Linux
 Package management: YUM repositories

 Repositories of RPM (RedHat Package Files)

 CentOS Advantages
 Enterprise Linux Distribution
 CentOS is equivalent to RHEL, a popular commercial Linux distro
 Learning CentOS (free) is a proxy for learning RHEL (not free)
 Only stable versions of software packages  fewer crashes & errors
 Fewer releases, more stable, lightweight, fast

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

CENTOS 7 – VIRTUAL MACHINE

Institute of Technology

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

C PROGRAMING IN TCSS 422

 Computerworld, 2017 Tech Forecast Survey  https://www.tacoma.uw.edu/institute-technology/student-
support-workshops-mentors
 Institute of Technology Mentors
 Located in Science 106 / 108 Labs
 Monday – Thursday: ~10 am – 7 pm
 Friday: ~ 1 2-5pm
 Spring Hours to be posted

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

C MENTORING

 Office hours: to be announced, and by appointment
 Due to teaching schedule (TCSS 562 @ 1 2:50pm) only limited
availability immediately after class sessions
 End of class: quick questions, assignment Q&A

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

INSTRUCTOR HELP

 Questions and discussion are encouraged
 Daily feedback surveys
 Helpful to know if topics are not clear
 Use the survey to write questions that come to you during the lecture

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

CLASS PARTICIPATION

 Responsible for:  Making it easy to run programs  Allowing programs to share memory  Enabling programs to interact with devices March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

OPERATING SYSTEMS

OS is in charge of making sure the system operates correctly and efficiently.  The OS is a resource manager  Manages CPU, disk, network I/O  Enables many programs to  Share the CPU  Share the underlying physical memory (RAM)  Share physical devices

 Disks
 Network Devices

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

RESOURCE MANAGEMENT

Institute of Technology

 Runs forever, must Ctrl-C to halt…

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUALIZING THE CPU - 3

prompt> gcc prompt> ./cpu "A" -o cpu cpu.c -Wall A A A ˆC prompt> March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUALIZATION THE CPU - 4

prompt> ./cpu A [1] 7353 & ; ./cpu B & ; ./cpu C & ; ./cpu D & [2] 7354 [3] 7355 [4] 7356 A B D C A B D C A C B D ... Even though we have only programs seem to be running one processor at the same time, all four of!

 Computer memory is treated as a large array of bytes
 Programs store all data in this large array
 Read memory (load)
 Specify an address to read data from
 Write memory (store)
 Specify data to write to an address

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUALIZING MEMORY

 Program to read/write memory:

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUALIZING MEMORY - 2

12 #include#include <unistd.h><stdio.h> 34 #include#include <stdlib.h>"common.h" (^56) int 78 main({ int argc, char *argv[]) 9 int *p = malloc(sizeof(int)); memory // a1: allocate some 1011 assert(pprintf("(%d) != NULL address); of p: %08x\n", 12 getpid(), (unsigned) address p); (^) of the// a2: memmoryprint out the 1314 p =while 0 ;( (^1) )// a3: { put zero into the first slot of the memory 1516 Spin(p = *p 1 ); + 1 ; (^1718) } printf("(%d) p: %d\n", getpid(), *p); // a (^1920) } return 0 ;

 Output of mem.c
 int value stored at 00200000
 program increments int value

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUALIZING MEMORY - 3

prompt> (2134) memory address./mem of p: 00200000 (2134) (2134) p:p: (^12) (2134) (2134) p:p: (^34) (2134) ˆC p: 5

 Multiple instances of mem.c
 (int*)p receives the same memory location 00200000
 Why does modifying (int*)p in program #1 (PID=24113), not
interfere with (int*)p in program #2 (PID=24114)?
 The OS has “virtualized” memory, and provides a “virtual” address

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUALIZING MEMORY - 4

prompt> ./mem &; ./mem & [1] 24113 [2] 24114 (24113) memory address of p: 00200000 (24114) memory (24113) p: 1 address of p: 00200000 (24114) p: 1 (24114) p: 2 (24113) p: 2 (24113) p: 3 (24114) p: 3 ...

Institute of Technology

 Key take-aways:

 Each process (program) has its own vir tual address space
 The OS maps virtual address spaces onto
physical memory
 A memory reference from one process can not affect the
address space of others.

 Isolation

 Physical memory, a shared resource, is managed by the OS

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

VIRTUAL MEMORY

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

CONCURRENCY

 Linux: 654 tasks
 Windows: 37 processes
 The OS appears to run many programs at once, juggling them
 Modern multi-threaded programs feature concurrent threads
and processes
 What is a key difference between processes and threads?

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

CONCURRENCY

Listing continues …

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

CONCURRENCY - 2

12 #include#include <stdio.h><stdlib.h> 34 #include "common.h" 56 volatile intint loops; counter = 0 ; (^78) void *worker(void *arg) { 910 intfor i;(i = 0 ; i < loops; i++) { (^1112) } counter++; (^1314) } return NULL; 15 ... Not the same as Java volatile:

Provides a compiler hint than an object may change value
unexpectedly (in this case by a separate thread) so aggressive
optimization must be avoided.
 Program creates two threads
 Check documentation: “man pthread_create”
 worker() method counts from 0 to argv[1] (loop)

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

CONCURRENCY - 3

1617 intmain(int argc, char *argv[]) 1819 { if (argc != 2 ) { 2021 fprintf(stderr,exit( 1 ); "usage: threads \n"); 2223 }loops = atoi(argv[ 1 ]); 2425 pthread_t p1, p2;printf("Initial value : %d\n", counter); (^2627) Pthread_create(&p1, NULL, worker, NULL); 2829 Pthread_create(&p2,Pthread_join(p1, NULL NULL);, worker, NULL); 3031 Pthread_join(p2,printf("Final value : %d\n", NULL); counter); (^3233) } return 0 ; March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

Institute of Technology

 Reliability
 OS must not crash, 24/7 Up-time
 Poor user programs must not bring down the system:
Blue Screen
 Other Issues
 Energy-efficiency
 Security (of data)
 Cloud: Virtual Machines

March 28, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L1.

SUMMARY:

OPERATING SYSTEM DESIGN GOALS - 2 QUESTIONS