today s objec4ves
play

Todays Objec4ves Threads and Synchroniza4on Wrap up Services Sept - PDF document

9/25/17 Todays Objec4ves Threads and Synchroniza4on Wrap up Services Sept 25, 2017 Sprenkle - CSCI325 1 Review What is the goal of TCP? What are some of the approaches it uses to meet these goals? Compare and contrast


  1. 9/25/17 Today’s Objec4ves • Threads and Synchroniza4on Wrap up • Services Sept 25, 2017 Sprenkle - CSCI325 1 Review • What is the goal of TCP? Ø What are some of the approaches it uses to meet these goals? • Compare and contrast threads and processes • What problem is caused by light-weight threads? Sept 25, 2017 Sprenkle - CSCI325 2 1

  2. 9/25/17 Review: Threads and Processes: Execu4on Environments • Execu4on environments Ø address space (memory) Ø thread synchroniza4on and communica4on resources (sockets) Ø higher-level resources likes open files • Each process has its own separate execu4on environment • Threads share a single execu4on environment code data files code data files registers registers registers stack stack stack Main thread: Process Mul+ple Threads Sept 25, 2017 Sprenkle - CSCI325 3 Threads vs. Processes • Benefits of using threads instead of processes Ø Low communica4on/context switching overhead since execu4on environment/address space is shared Ø Easy to take advantage of parellelism mul4-processor computers • Disadvantages of threads Ø Shared resources can lead to synchroniza4on problems Ø Need to be careful to avoid deadlocks Ø Need to provide atomic opera4ons Sept 25, 2017 Sprenkle - CSCI325 4 2

  3. 9/25/17 Exploring Issues with Shared Data • Shared Data: an array list (representa4on: Deck of Cards) • Discussion Ø What are the problema4c situa4ons? Ø What causes them? Ø How can you prevent problema4c situa4ons? • Mo4vates synchroniza4on mechanisms Sept 25, 2017 Sprenkle - CSCI325 5 Cri4cal Sec4ons and Synchroniza4on Mechanisms • Cri(cal sec(on : Sec4ons of code that have to happen uninterrupted or atomically Ø Only one thread can execute at a 4me Ø O^en issue of writes among reads • Synchroniza(on mechanism: Lock Ø Prevent more than one thread from accessing cri4cal sec4on at same 4me Ø If thread is interrupted while in the synchronized cri4cal sec4on, no other thread can start on the (synchronized) cri4cal sec4on Sept 25, 2017 Sprenkle - CSCI325 6 3

  4. 9/25/17 Problems • Interrupted writes to shared data Ø Allows threads to access inconsistent data • (Not an issue if the data is local to the thread) • Example: Mul4ple threads run the following code on the shared variable deck myCard = deck.peek() // check, do I want that card? deck.pop() print(myCard) Sept 25, 2017 Sprenkle - CSCI325 7 Interleaving Example Problem myCard = deck.peek() myCard = deck.peek() deck.pop() deck.pop() print(myCard) print(myCard) Threads interleaved: myCard = deck.peek() myCard = deck.peek() deck.pop() print(myCard) deck.pop() print(myCard) What card does the blue thread pop ? What is the critical section? (i.e., what code needs to executed atomically (without interruption)?) Sept 25, 2017 Sprenkle - CSCI325 8 4

  5. 9/25/17 Interleaving Example Problem Critical Section: myCard = deck.peek() Atomic operation that needs to be deck.pop() done together print(myCard) Printing does not need to be part of the critical section. Why? While deck is a shared variable, myCard is a local variable. Sept 25, 2017 Sprenkle - CSCI325 9 Synchroniza4on in Java // Only one thread can execute at a time. // The thread executing the block is said // to hold the lock/monitor of the deck // object synchronized(deck) { // Access shared variables and other // shared resources myCard = deck.peek() deck.pop() } System.out.println(myCard) Sept 25, 2017 Sprenkle - CSCI325 10 5

  6. 9/25/17 Is there shared data in the web server? 210 in 325 • Even if only one Java statement in cri4cal sec4on, synchronize it! • One high-level Programming Language statement probably translates into mul4ple VM language statements Ø Prevent interrup4on at low level High-level: Virtual Machine level: count++; Retrieve count Add 1 to count Store count Sept 25, 2017 Sprenkle - CSCI325 11 How does this relate to the Web Server? • We have mul4ple threads • Is there shared data? Is that data ever wrieen? Sept 25, 2017 Sprenkle - CSCI325 12 6

  7. 9/25/17 INTERNET SERVICES Sept 25, 2017 Sprenkle - CSCI325 13 Discussion • What is the focus of the paper? Ø What isn’t? • What is the author’s experience? • What did the author iden4fy as challenges to giant-scale services? • What are the benefits of networked solu4ons? • What are the components of the network service system? Sept 25, 2017 Sprenkle - CSCI325 14 7

  8. 9/25/17 Benefits of Network Services • Access anywhere, any4me Ø This is even more true now than it was in 2001 Ø Cloud compu4ng? • Availability via mul4ple devices Ø Also more true… • Groupware support Ø Calendaring, teleconferencing, messaging, etc. • Lower overall cost Ø Mul4plex infrastructure over ac4ve users Ø Dedicated resources are typically at least 96% idle Ø Central administra4ve burden, simplified end devices • Simplified service updates Ø Update the service in one place, or 100 million? Sept 25, 2017 Sprenkle - CSCI325 15 Giant-Scale Services • Paper does not address Ø Service monitoring, configura4on, QoS, security, logging, and log analysis Ø Wide-area replicated services Ø Write-intensive services Ø Database management systems • Challenges for network services: Ø High availability • Cri4cal in today’s Internet-dependent society • Each second of down4me = lots of lost money and revenue Ø Evolu4on Ø Growth Sept 25, 2017 Sprenkle - CSCI325 16 8

  9. 9/25/17 Buzzword Bingo: ISP • + Net Neutrality Sept 25, 2017 Sprenkle - CSCI325 17 ISP: Internet Service Provider • Provides connec4ons to the rest of the Internet • Net neutrality Ø Providers want to give preference to certain types of traffic • Ex: Slow down Nenlix traffic on Comcast network so that people will prefer Comcast On-Demand Ø Net neutrality advocates want all traffic to be seen as equal – no dis4nc4on • Way it has always been, your expecta4on Sept 25, 2017 Sprenkle - CSCI325 18 9

  10. 9/25/17 Cluster Discussion • What is the case for clusters? Ø Is it s4ll true? • What do they consist of? Sept 25, 2017 Sprenkle - CSCI325 19 Buzzword: Commodity Components • Defn: [rela4vely] cheap components, widely available, interchangeable Ø “Off-the-shelf” components • Allow crea4on of [rela4vely] cheap clusters of machines that work together • In contrast to specialty hardware, e.g., supercomputers Sept 25, 2017 Sprenkle - CSCI325 20 10

  11. 9/25/17 Network Service Components 1 2 3 6 4 Server 5 Sept 25, 2017 Sprenkle - CSCI325 21 Clusters as Building Blocks • No alterna4ve to clusters for building network services that can scale to global use • Cluster benefits: Ø Incremental scalability • Adding one machine typically linearly improves performance Ø Independent components Ø Cost and performance Sept 25, 2017 Sprenkle - CSCI325 22 11

  12. 9/25/17 Looking Ahead • Web Server Project! Sept 25, 2017 Sprenkle - CSCI325 23 12

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