today s objec3ves
play

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


  1. 9/22/17 Today’s 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 that func3onality? Sept 22, 2017 Sprenkle - CSCI325 2 1

  2. 9/22/17 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 2

  3. 9/22/17 SERVICES: BUZZWORD BINGO Sept 22, 2017 Sprenkle - CSCI325 5 Perusall • What works, what doesn’t? Sept 22, 2017 Sprenkle - CSCI325 6 3

  4. 9/22/17 Buzzword Bingo • Document on Box Sept 22, 2017 Sprenkle - CSCI325 7 PROCESSES AND THREADS Sept 22, 2017 Sprenkle - CSCI325 8 4

  5. 9/22/17 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 5

  6. 9/22/17 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 opera3ons, 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 code data files code data files registers registers registers stack stack stack Main thread: Process MulAple Threads Sept 22, 2017 Sprenkle - CSCI325 12 6

  7. 9/22/17 Threads vs Processes If this were an OS class, would discuss threads and processes for weeks • Your book discusses them briefly Process Thread • “thread of execu3on” • Single ac3vity that processor can execute • “Lightweight” • “Heavyweight” • Shares state informa3on • Independent tasks with other threads within a single process • Have a private address Ø Every process has a space thread • Only interact with other • Easily interact with other processes through inter- threads b/c memory is process communica3on shared Sept 22, 2017 Sprenkle - CSCI325 13 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 Sprenkle - CSCI325 14 7

  8. 9/22/17 Synchronizing Threads • Have shared data Ø What helps threads be lightweight • Threads can be interrupted by the OS scheduler at any 3me What challenges does this present? How can we address these challenges? Sept 22, 2017 Sprenkle - CSCI325 15 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 8

  9. 9/22/17 Discussion • What are the opera3ons we can do to the array list? Ø Top card?, Draw card(s), Shuffle, Add cards, Cut deck 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) … Sept 22, 2017 Sprenkle - CSCI325 17 Discussion • What are the opera3ons we can do to the array list? Ø Top card?, Draw card(s), Shuffle, Add cards, Cut deck Thread1: Thread2: • deck.pop(0) • deck.get(0) • deck.pop(0) • deck.pop(0) Sept 22, 2017 Sprenkle - CSCI325 18 9

  10. 9/22/17 Exploring Issues with Shared Data • Shared Data: an array list (representa3on: Deck of 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 10

  11. 9/22/17 Looking Ahead • Web Server due next Friday Sept 22, 2017 Sprenkle - CSCI325 21 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend