1 cs120: lecture 7 mp johnson hunter [email protected]

21
1 CS120: Lecture 7 MP Johnson Hunter [email protected]

Post on 20-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

1

CS120: Lecture 7

MP Johnson

Hunter

[email protected]

2

Agenda• OSs: processes

• networks– Basics, def– Internet/web– Internet Applications

• FTP• telnet• HTTP/HTML

– Internet protocols/arch• TCP/IP

• HTML language

3

Multiple processes

• Very common:– Clock prog ticks– Doc prints– Browser loads– Playing game

• NT has >100 processes, before you run anything

• Some machines have mult processors– “dual-core”

• But usually >> processes running– Can’t simply assign 1 to each processor

time-sharing

4

Time-sharing

• Keep track of running processes in process table– Vars for each process– Where it’s at

• Divide time into time-slices– E.g., 50 ms

• At end of timeslice, have interrupt– Store info for curr proc in P.T.– Restart another process from where left off

5

Time-sharing

• Has some overhead– Memory of P.T.– Time to switch

• But overall saves time– Better uses time when waiting for user

• Modern OSs have “preemtive multitasking”• In Win 95/3.1, OS less strict about

interrupting often hung

6

Mult. procs compet for resources

• What if 2 progs want to print/draw/read at same time?

• Only 1 can have access at once, or else conflict OS must control access how?

• Simple idea: use a flag• 1/0, set/clear, says whether printer in use• On req, if clear, allow and set; o.w., make wait• When done, set clear, or give to waiting prog

7

Flags

• Countereg:

• Prog1 requests prn– Check: clear, so…INTERUPT…set and given

• Prog2 requests prn– Check: clear so…INTERUPT…set and given X

• Soln: make check-and-set a single op– “semaphore”

8

Spooling

• Related is spooling

• Won’t discuss strategies, but idea is:

• When app wants to send job to device, take it, keep in buffer until device is ready

• Common e.g.: print spooler

9

Deadlock

• Very serious problem• Two processes both waiting for resources,

– Both dependent on other– Both “block” each other

• P1: wants to upload from HD to netw card– Has HD access, waiting for netw access

• P2: wants to download from new to HD– Has netw access, waiting for HD access

deadlock!

10

Dining philosophers (Dijkstra)

• 5 philosophers eating sushi, around table• 5 chopsticks between them• To eat, phil must pick up two adjacent

chopsticks, one at time– Sets them down after each bite

• Goal: give strategy avoiding– Deadlock and– Starvation (of any phil)

11

Next: Networks

• Collection of connected entities– “nodes”

• Friends, colleagues – Friendster– Business people do “networking”

• Phones

• Cities (roads)

12

LANs

• LAN: local area network– Computers in building, campus– Connected to share common resources,

comm

• Novell, Microsoft

13

Internet

• Can connect LANs together

• Internet = network of networks– DARPA, 1973– Defense Advanced Research Projs Agency– Originally “ARPAnet”– Non-graphical

14

Connecting to Internet

• Large org: buy a direct connection

• Small org: link with ISP

• Individual: link to ISP (while connected)

15

Internet Arch• Each gp/company/school has domain

– microsoft.com– cuny.edu

• Names registered with ICANN– Internet Corp for Assigned Names & Netws

• Domain connected to Internet cloud w/ gateway

16

Internet addressing

• Each machine IP address– Internet Protocol– Ids domain and host (machine)

• Written in dotted decimal:– 192.207.177.133– First 3: domain– Last: host

17

CCNY IP[mjohnson@csfhome1 ~]$ whois 134.74.112.202[Querying whois.arin.net][whois.arin.net]

OrgName: City College of New York OrgID: CCNYAddress: 138th Street at Convent AvenueCity: New YorkStateProv: NYPostalCode: 10031Country: US

NetRange: 134.74.0.0 - 134.74.255.255 CIDR: 134.74.0.0/16 NetName: CITYCOLLEGENetHandle: NET-134-74-0-0-1Parent: NET-134-0-0-0-0NetType: Direct AssignmentNameServer: GPX.CCNY.CUNY.EDUNameServer: NS2.PSI.NETNameServer: MED1S0.ENGR.CCNY.CUNY.EDUNameServer: MES1S0.ENGR.CCNY.CUNY.EDUComment: RegDate: 1989-05-10Updated: 2000-02-23

18

IPs & domain names

• Usually don’t type IPs

• Type domain names– cuny.edu

• End in .edu, .com, .ca, etc.

• Can define subdomains:– ccny.cuny.edu

• For each link:– First look up IP for domain name– Name server

19

Network topologies

• Token-ring: IBM, 1970s• Msgs sent in one direction• Msg propagates until

returns to sender– Then removed

• Machine only can send if has the token

• After one successful msg, sends token to next

20

Network topologies

• Ethernet – bus-based

• To send msg, machine broadcasts to all

• 2 machines cannot send a msg at once

• If 2 try at once, both stop,– Wait random amount of time

• Like conversation

21

Future

• future: lab session/hw2– Goal: create and post a webpage

– Also written portion (done independently)