Todays Objec3ves TCP Wrap Up Services: Buzzword Bingo Threads and - - PDF document

today s objec3ves
SMART_READER_LITE
LIVE PREVIEW

Todays Objec3ves TCP Wrap Up Services: Buzzword Bingo Threads and - - PDF document

9/22/17 Todays Objec3ves TCP Wrap Up Services: Buzzword Bingo Threads and Synchroniza3on Sept 22, 2017 Sprenkle - CSCI325 1 Review What layer is TCP? What does it add that the lower level does not have? How does it add


slide-1
SLIDE 1

9/22/17 1

Today’s Objec3ves

  • TCP Wrap Up
  • Services: Buzzword Bingo
  • Threads and Synchroniza3on

Sept 22, 2017 1 Sprenkle - CSCI325

Review

  • What layer is TCP?

Ø What does it add that the lower level does not have? Ø How does it add that func3onality?

Sept 22, 2017 Sprenkle - CSCI325 2

slide-2
SLIDE 2

9/22/17 2

TCP Proper3es

  • Sequence Numbers, Acknowledgements

Numbers

Ø For ordering data Ø For iden3fying missing data, duplicate data

  • Timeout

Ø For lost data

  • Sliding Window

Ø For flow control, conges3on control Ø (not just 8 packets)

Sept 22, 2017 Sprenkle - CSCI325 3

TCP Flow Control

  • TCP is a sliding window protocol based on byte

streams, not packets

Ø For window size n, can send up to n bytes without receiving an acknowledgement Ø When the data is acknowledged, window slides forward

  • Each packet adver3ses a window size inside TCP

header field

Ø Number indicates number of bytes the receiver is willing to buffer

Sept 22, 2017 Sprenkle - CSCI325 4

slide-3
SLIDE 3

9/22/17 3

SERVICES: BUZZWORD BINGO

Sept 22, 2017 Sprenkle - CSCI325 5

Perusall

  • What works, what doesn’t?

Sept 22, 2017 Sprenkle - CSCI325 6

slide-4
SLIDE 4

9/22/17 4

Buzzword Bingo

  • Document on Box

Sept 22, 2017 Sprenkle - CSCI325 7

PROCESSES AND THREADS

Sept 22, 2017 Sprenkle - CSCI325 8

slide-5
SLIDE 5

9/22/17 5

What is a Process?

  • Process – a sequen3al program execu3on
  • Ideally, we would like our OS to be capable of

running mul3ple processes/jobs at once (i.e., mul&programming)

  • Challenge: how to implement & ensure efficient

use of system resources?

Sept 22, 2017 Sprenkle - CSCI325 9

Difference between a process and a program

  • Baking analogy:

Ø Recipe = Program Ø Baker = Processor Ø Ingredients = data Ø Baking the cake = Process

Sept 22, 2017 Sprenkle - CSCI325 10

slide-6
SLIDE 6

9/22/17 6

Crea3ng the Illusion of Concurrency

  • Interleave the execu3on of exis3ng processes to

maximize processor u3liza3on

Ø Idea: while one process is blocked on (slow) I/O

  • pera3ons, allow another process to have the CPU to

make progress

  • Provides the illusion of concurrency on a one-

processor system

  • Provide reasonable response 3mes to processes

Sept 22, 2017 Sprenkle - CSCI325 11

Threads and Processes: Execu3on Environments

  • Execu3on environments

Ø address space (memory) Ø thread synchroniza3on and communica3on resources (sockets) Ø higher-level resources likes open files

  • Each process has its own separate execu3on environment
  • Threads share a single execu3on environment

Sept 22, 2017 Sprenkle - CSCI325 12

code data files registers stack code data files registers stack registers stack

Process

Main thread:

MulAple Threads

slide-7
SLIDE 7

9/22/17 7

Threads vs Processes

Process

  • Single ac3vity that

processor can execute

  • “Heavyweight”
  • Independent tasks
  • Have a private address

space

  • Only interact with other

processes through inter- process communica3on Thread

  • “thread of execu3on”
  • “Lightweight”
  • Shares state informa3on

with other threads within a single process

Ø Every process has a thread

  • Easily interact with other

threads b/c memory is shared

Sept 22, 2017 Sprenkle - CSCI325 13

If this were an OS class, would discuss threads and processes for weeks

  • Your book discusses them briefly

Threads vs. Processes

  • Benefits of using threads instead of processes

Ø Low communica3on/context switching overhead since execu3on environment/address space is shared Ø Easy to take advantage of parellelism mul3-processor computers

  • Disadvantages of threads

Ø Shared resources can lead to synchroniza3on problems Ø Need to be careful to avoid deadlocks Ø Need to provide atomic opera3ons

Sept 22, 2017 14 Sprenkle - CSCI325

slide-8
SLIDE 8

9/22/17 8

Synchronizing Threads

  • Have shared data

Ø What helps threads be lightweight

  • Threads can be interrupted by the OS scheduler

at any 3me

Sept 22, 2017 Sprenkle - CSCI325 15

What challenges does this present? How can we address these challenges?

Exploring Issues with Shared Data

  • Shared Data: an array list (representa3on: Deck of

Cards)

  • Discussion

Ø What are the opera3ons we can do to the array list? Ø How might we have mul3ple threads interac3ng with the list?

  • What would the code look like?

Ø Assign people to these roles, ac3ng as concurrent threads

  • Play out different scenarios: how could the threads

interleave?

Ø Consider what the code would look like

Sept 22, 2017 Sprenkle - CSCI325 16

slide-9
SLIDE 9

9/22/17 9

Discussion

  • What are the opera3ons we can do to the array

list?

Ø Top card?, Draw card(s), Shuffle, Add cards, Cut deck

Sept 22, 2017 Sprenkle - CSCI325 17

def addCard(self, card): self.cards.append(card) def removeCard(self, card): self.cards.remove(card) def topCard(self): return self.cards.get(0) def shuffle(self): random.shuffle(self.cards) …

Discussion

  • What are the opera3ons we can do to the array

list?

Ø Top card?, Draw card(s), Shuffle, Add cards, Cut deck

Sept 22, 2017 Sprenkle - CSCI325 18

Thread1:

  • deck.pop(0)
  • deck.pop(0)

Thread2:

  • deck.get(0)
  • deck.pop(0)
slide-10
SLIDE 10

9/22/17 10

Exploring Issues with Shared Data

  • Shared Data: an array list (representa3on: Deck
  • f Cards)
  • Discussion

Ø What are the problema3c situa3ons? Ø What causes them? Ø How can you prevent problema3c situa3ons?

  • Mo3vates synchroniza3on mechanisms

Sept 22, 2017 Sprenkle - CSCI325 19

Cri3cal Sec3on

  • Sec3ons of code that have to happen

uninterrupted or atomically

Ø Only one thread can execute at a 3me

Sept 22, 2017 Sprenkle - CSCI325 20

slide-11
SLIDE 11

9/22/17 11

Looking Ahead

  • Web Server due next Friday

Sept 22, 2017 Sprenkle - CSCI325 21