SlideShare une entreprise Scribd logo
1  sur  39
Plan for Today
• First Three Files
• Why Concurrency Is Hard
– Race Conditions
– Deadlocks
• MapReduce!
• Problem Set 3
8 October 2013 University of Virginia cs4414 1
When you create a new repo, what
should the second file you add be?
8 October 2013 University of Virginia cs4414 2
Makefiles
• Someone should be able to clone your repo
and build it by doing: gash> make
• Even if no one else ever clones your repo, you
will be very happy to have this if you come
back to it a few weeks later
8 October 2013 University of Virginia cs4414 3
The only excuse for not having a Makefile is if you use configure to create a
platform-specific one (like rust does): ./configure; make && make install
Making Makefiles
8 October 2013 University of Virginia cs4414 4
# cs4414 Problem Set 3
all: zhtta
zhtta:
rustc zhtta.rs
Beware: awkward, quirky syntax:
<space><space><space><space><space> ≠ <tab>
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
…
Complex projects have complex Makefiles:
but to build them, all you need to know is make
When you create a new repo, what
should the third file you add be?
8 October 2013 University of Virginia cs4414 5
LICENSE
8 October 2013 University of Virginia cs4414 6
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This is the MIT License, taken from the Rust repo. Rust license is a
more complicated (parts are MIT, parts are Apache).
Includethispartbecauseyou
wantotherstocontributeto
andbenefitfromyourcode.
Include this part because you want to be protected if
the government decides to use your zhtta to run
healthcare.gov (but keep the ALLCAPS to ensure no
one wastes time reading it).
8 October 2013 University of Virginia cs4414 7
This work is licensed
under a Creative
Commons
Attribution-
NonCommercial 2.5
License.
This means that you
are free to copy and
reuse any of my
drawings
(noncommercially) as
long as you tell
people where they're
from.
(Its from xkcd.com)
First File?
1. ?
2. Makefile
3. LICENSE
8 October 2013 University of Virginia cs4414 8
Can we start writing some code please!?!??
(Note: you are not required to use a permissive
LICENSE for code you write for this class, but
anything you derive from our starting code must
follow the LICENSE provided there.)
First File: README.md
1. README.md
2. Makefile
3. LICENSE
8 October 2013 University of Virginia cs4414 9
Now, start writing code… (or documentation!)
You may think this seems silly for
small programs. But, every
big, complex program started out
as a small one. A few minutes
setting up your repo will be
worth it in the long run.
8 October 2013 University of Virginia cs4414 10
“You can use them freely (with some kind of link) in not-for-profit
publications, and I’m also okay with people reprinting occasional
comics (with clear attribution) in publications like
books, blogs, newsletters, and presentations. If you’re not sure
whether your use is noncommercial, feel free to email me and
ask (if you’re not sure, it's probably okay).” (Detailed explanation
of xkcd license.)
Synchronization
Scheduling Meetings
Bob Alice Colleen“When can
you meet
Friday?”
“When can
you meet
Friday?”
“11am or 3pm”
“9am or 11am”
“11am it is” “11am it is.”
Reserves 11am
for meeting
Reserves 11am
for meeting
Selects and
reserves 11am
Partial Ordering of Events
• Sequential programs give us a total ordering
of events: everything happens in a
determined (sequential) order
• Concurrent programs give us a partial
ordering of events: we know some things
happen before other things, but other
orderings are undetermined
Bob Alice Colleen“When can
you meet
Friday?”
“When can
you meet
Friday?”
“11am or 3pm”
“9am or 11am”
“11am it is” “11am it is.”
Reserves 11am
for meeting
Reserves 11am
for meeting
Selects and
reserves 11am
A1
A2
B1
C1
A3
A4 A5
B2 C2
Race Condition
• Race Condition: Behavior of a program
depends on order of events
• Data race: two threads read and write shared
data in a way such that ordering of events
changes resulting state
• Time-of-check-to-time-of-use: thread 1
checks some property, thread 2 modifies
it, thread 1 does something based on the out-
of-date check
8 October 2013 University of Virginia cs4414 14
Bob Alice Colleen“When can
you meet
Friday?”
“When can
you meet
Friday?”
“11am or 3pm”
“9am or 11am”
“11am it is” “11am it is.”
Reserves 11am
for meeting
Reserves 11am
for meeting
Selects and
reserves 11am
A1
A2
B1
C1
A3
A4 A5
B2 C2
Any race conditions here?
Bob Alice Colleen“When can
you meet
Friday?”
“When can
you meet
Friday?”
“11am or 3pm”
“9am or 11am”
“11am it is” “11am it is.”
Reserves
11am
Reserves
11am
Selects and
reserves 11am
A1
A2
B1
C1
A3
A4 A5
B2 C2
Dave
“When can
you meet
Friday?”
“9am or
11am”
D2
“Ok, 11am.” Selects
and
reserves
11am
Preventing Data Races
• Use locks to impose ordering constraints
• After responding to Alice, Coleen reserves all
the times in response until she hears back
Bob Alice Colleen“When can
you meet
Friday?”
“When can
you meet
Friday?”
“11am or 3pm”
“9am”
Reserves
11am
A1
A2
B1
C1
Dave
“When can
you meet
Friday?”
“9am or
11am”
D2
“Ok, 11am.” Selects
and
reserves
11am
While Colleen’s calendar is locked, cannot allow Alice to read it!
Bob Alice Colleen“When can
you meet
Friday?”
“When can
you meet
Friday?”
“11am or 3pm”
A1
A2
B1
Dave
“When can
you meet
Friday?”
“9am or
11am”
“Bob, w
hen can
you
meet
Friday?”
Deadlock
Deadlock: A group of threads are stuck because
of resource dependencies
8 October 2013 University of Virginia cs4414 20
Thread A
Resource 1
Resource 2
Thread B
Locks
Locks
Needs
Needs
Why are threads hard?
• Too few ordering constraints: race conditions
• Too many ordering constraints: deadlocks
• Hard/impossible to reason modularly
If an object is accessible to multiple threads, need to think
about what any of those threads could do at any time!
• Testing is even more impossible than it is for
sequential code: even if you test all the inputs, don’t know
it will work if threads run in different order
Rust makes safe threads easy(er)!
Safe Rust Code
Is it possible to have a data race condition?
Is it possible to have a deadlock?
8 October 2013 University of Virginia cs4414 22
Multi-Rustic Map-Reduce
8 October 2013 University of Virginia cs4414 23
Alexander Lamana
Jasdev Singh
Nishant Shukla
William Thomason
Problem Set 3: Zhtta web server
8 October 2013 University of Virginia cs4414 24
8 October 2013 University of Virginia cs4414 25
Yesterday’s
Top Story
8 October 2013 University of Virginia cs4414 26
8 October 2013 University of Virginia cs4414 27
“In some cases, the Web site does not
recognize users who established accounts
before Oct. 1, when the online marketplaces
opened for consumers to shop for insurance.
Other users are prevented from establishing
accounts. Some who successfully established a
marketplace account received an e-mail asking
them to verify their e-mail addresses, but the
link provided did not work.” (NYT article)
Race condition, deadlock, or
general crappiness?
Is it unusual for a web service to
face 1M requests in a day?
8 October 2013 University of Virginia cs4414 28
reddit.com
Google: over 5 Billion searches per day (average for 2012)
8 October 2013 University of Virginia cs4414 29
“But because of the initial failures, other parts of the
complex system have yet to be proved under the
intense strain of real-world conditions. And outside
experts said that White House officials should have
spent more time tending to the computer code and
technology of the Web site, rather than recruiting
Hollywood celebrities to promote it.”
…
Those comments echoed similar criticism on sites
across the Internet, where Web designers and
developers speculated about the reasons for the
ongoing problems at the Web site, healthcare.gov. One
discussion on the popular Web site reddit.com was
titled “How not to optimize a website.”
8 October 2013 University of Virginia cs4414 30
White House officials declined to identify the private contractors
who had built the account creation function, citing a decision to
keep that information private. They said the contractors had
moved that part of the new system to beefed-up hardware and
were busy rewriting the software code to make it more robust
and efficient. In the past week, wait times have dropped by
half, officials said.
Officials said they had also added staff members at call centers
to provide customers an alternative to the online system. The
Web site currently says that people “in a hurry” can apply
faster at a government call center using a toll-free telephone
number, (800) 318-2596. But an operator at the call center said
Monday that he could not help because he, too, was
“experiencing technical difficulties with the Web site.”
Ouch…what was today’s top story?
8 October 2013 University of Virginia cs4414 31
8 October 2013 University of Virginia cs4414 32
NSA Meltdown
8 October 2013 University of Virginia cs4414 33
“Experts estimate the
new center in Utah can
store data by the
exabyte or zettabyte.”
z vs. Z
8 October 2013 University of Virginia cs4414 34
Minimum energy needed to flip one bit
(Landauer limit) ≈ kT ln 2 ≈ 2.8 zJ (zeptoJoules)
Energy NSA would need to brute-force AES 128-
bit keys ≈ 1.0 ZJ
8 October 2013 University of Virginia cs4414 35
8 October 2013 University of Virginia cs4414 36
Problem Set 3
• Your Zhtta server will probably not actually be
1042 times better than zhttpo!
• Putting the Z in zhtta:
– A safe shared counter
– Flexible scheduling (including prioritizing
Charlottesville requests)
– Smart page caching
– Server-side gash scripts
– Your interesting extensions and performance
improvements
8 October 2013 University of Virginia cs4414 37
PS3 is due
Monday, 28 October
Finding PS3 Teams
8 October 2013 University of Virginia cs4414 38
Rule: team of 2 or 3, cannot be the exact same team you
had for PS2 (teams of 3 can include a PS2 team)
Team A Team B Team C
Challenging
asynchronous
resource contention
problem with many
possible deadlocks!
Try to solve it
synchronously now.

Contenu connexe

Similaire à Synchronization

Heartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and SolutionHeartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and SolutionCASCouncil
 
New Era of Software with modern Application Security v1.0
New Era of Software with modern Application Security v1.0New Era of Software with modern Application Security v1.0
New Era of Software with modern Application Security v1.0Dinis Cruz
 
Douglas Crockford - Ajax Security
Douglas Crockford - Ajax SecurityDouglas Crockford - Ajax Security
Douglas Crockford - Ajax SecurityWeb Directions
 
Dmk sb2010 web_defense
Dmk sb2010 web_defenseDmk sb2010 web_defense
Dmk sb2010 web_defenseDan Kaminsky
 
Engineering culture
Engineering cultureEngineering culture
Engineering culturePamela Fox
 
How to Destroy a Database
How to Destroy a DatabaseHow to Destroy a Database
How to Destroy a DatabaseJohn Ashmead
 
Douglas - Real JavaScript
Douglas - Real JavaScriptDouglas - Real JavaScript
Douglas - Real JavaScriptd0nn9n
 
Anatomy of Java Vulnerabilities - NLJug 2018
Anatomy of Java Vulnerabilities - NLJug 2018Anatomy of Java Vulnerabilities - NLJug 2018
Anatomy of Java Vulnerabilities - NLJug 2018Steve Poole
 
Building Secure Open & Distributed Social Networks
Building Secure Open & Distributed Social NetworksBuilding Secure Open & Distributed Social Networks
Building Secure Open & Distributed Social NetworksHenry Story
 
AdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docx
AdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docxAdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docx
AdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docxgalerussel59292
 
Datasets, APIs, and Web Scraping
Datasets, APIs, and Web ScrapingDatasets, APIs, and Web Scraping
Datasets, APIs, and Web ScrapingDamian T. Gordon
 
Creating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersCreating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersPaul Balogh
 
(java2days) The Anatomy of Java Vulnerabilities
(java2days) The Anatomy of Java Vulnerabilities(java2days) The Anatomy of Java Vulnerabilities
(java2days) The Anatomy of Java VulnerabilitiesSteve Poole
 
Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...
Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...
Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...Andreas Grabner
 
Which Freaking Database Should I Use?
Which Freaking Database Should I Use?Which Freaking Database Should I Use?
Which Freaking Database Should I Use?Great Wide Open
 
Toward a Mobile Data Commons
Toward a Mobile Data CommonsToward a Mobile Data Commons
Toward a Mobile Data CommonskingsBSD
 
Oracle database threats - LAOUC Webinar
Oracle database threats - LAOUC WebinarOracle database threats - LAOUC Webinar
Oracle database threats - LAOUC WebinarOsama Mustafa
 

Similaire à Synchronization (20)

Heartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and SolutionHeartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and Solution
 
Walter api
Walter apiWalter api
Walter api
 
New Era of Software with modern Application Security v1.0
New Era of Software with modern Application Security v1.0New Era of Software with modern Application Security v1.0
New Era of Software with modern Application Security v1.0
 
Douglas Crockford - Ajax Security
Douglas Crockford - Ajax SecurityDouglas Crockford - Ajax Security
Douglas Crockford - Ajax Security
 
Dmk sb2010 web_defense
Dmk sb2010 web_defenseDmk sb2010 web_defense
Dmk sb2010 web_defense
 
Engineering culture
Engineering cultureEngineering culture
Engineering culture
 
Website qa
Website qaWebsite qa
Website qa
 
How to Destroy a Database
How to Destroy a DatabaseHow to Destroy a Database
How to Destroy a Database
 
Douglas - Real JavaScript
Douglas - Real JavaScriptDouglas - Real JavaScript
Douglas - Real JavaScript
 
Anatomy of Java Vulnerabilities - NLJug 2018
Anatomy of Java Vulnerabilities - NLJug 2018Anatomy of Java Vulnerabilities - NLJug 2018
Anatomy of Java Vulnerabilities - NLJug 2018
 
Building Secure Open & Distributed Social Networks
Building Secure Open & Distributed Social NetworksBuilding Secure Open & Distributed Social Networks
Building Secure Open & Distributed Social Networks
 
AdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docx
AdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docxAdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docx
AdvanceStorage.zipyyy.docxMOVIE VIEWS SYSTEMProp.docx
 
Datasets, APIs, and Web Scraping
Datasets, APIs, and Web ScrapingDatasets, APIs, and Web Scraping
Datasets, APIs, and Web Scraping
 
Creating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersCreating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with Testcontainers
 
(java2days) The Anatomy of Java Vulnerabilities
(java2days) The Anatomy of Java Vulnerabilities(java2days) The Anatomy of Java Vulnerabilities
(java2days) The Anatomy of Java Vulnerabilities
 
Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...
Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...
Performance Quality Metrics for Mobile Web and Mobile Native - Agile Testing ...
 
Which Freaking Database Should I Use?
Which Freaking Database Should I Use?Which Freaking Database Should I Use?
Which Freaking Database Should I Use?
 
What is web scraping?
What is web scraping?What is web scraping?
What is web scraping?
 
Toward a Mobile Data Commons
Toward a Mobile Data CommonsToward a Mobile Data Commons
Toward a Mobile Data Commons
 
Oracle database threats - LAOUC Webinar
Oracle database threats - LAOUC WebinarOracle database threats - LAOUC Webinar
Oracle database threats - LAOUC Webinar
 

Plus de David Evans

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!David Evans
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksDavid Evans
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeDavid Evans
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in BitcoinDavid Evans
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm ConfirmationsDavid Evans
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting TransactionsDavid Evans
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in ParadiseDavid Evans
 
Mining Economics
Mining EconomicsMining Economics
Mining EconomicsDavid Evans
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More ParanoidDavid Evans
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key SignaturesDavid Evans
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyDavid Evans
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?David Evans
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the MassesDavid Evans
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of ReserveDavid Evans
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!David Evans
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinDavid Evans
 

Plus de David Evans (20)

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in Bitcoin
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm Confirmations
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting Transactions
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in Paradise
 
Bitcoin Script
Bitcoin ScriptBitcoin Script
Bitcoin Script
 
Mining Economics
Mining EconomicsMining Economics
Mining Economics
 
Mining
MiningMining
Mining
 
The Blockchain
The BlockchainThe Blockchain
The Blockchain
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More Paranoid
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key Signatures
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the Masses
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of Reserve
 
Silk Road
Silk RoadSilk Road
Silk Road
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
 

Dernier

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Dernier (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Synchronization

  • 1.
  • 2. Plan for Today • First Three Files • Why Concurrency Is Hard – Race Conditions – Deadlocks • MapReduce! • Problem Set 3 8 October 2013 University of Virginia cs4414 1
  • 3. When you create a new repo, what should the second file you add be? 8 October 2013 University of Virginia cs4414 2
  • 4. Makefiles • Someone should be able to clone your repo and build it by doing: gash> make • Even if no one else ever clones your repo, you will be very happy to have this if you come back to it a few weeks later 8 October 2013 University of Virginia cs4414 3 The only excuse for not having a Makefile is if you use configure to create a platform-specific one (like rust does): ./configure; make && make install
  • 5. Making Makefiles 8 October 2013 University of Virginia cs4414 4 # cs4414 Problem Set 3 all: zhtta zhtta: rustc zhtta.rs Beware: awkward, quirky syntax: <space><space><space><space><space> ≠ <tab> # Suffix rules, putting all outputs into $(obj). $(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD @$(call do_cmd,cc,1) … Complex projects have complex Makefiles: but to build them, all you need to know is make
  • 6. When you create a new repo, what should the third file you add be? 8 October 2013 University of Virginia cs4414 5 LICENSE
  • 7. 8 October 2013 University of Virginia cs4414 6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This is the MIT License, taken from the Rust repo. Rust license is a more complicated (parts are MIT, parts are Apache). Includethispartbecauseyou wantotherstocontributeto andbenefitfromyourcode. Include this part because you want to be protected if the government decides to use your zhtta to run healthcare.gov (but keep the ALLCAPS to ensure no one wastes time reading it).
  • 8. 8 October 2013 University of Virginia cs4414 7 This work is licensed under a Creative Commons Attribution- NonCommercial 2.5 License. This means that you are free to copy and reuse any of my drawings (noncommercially) as long as you tell people where they're from. (Its from xkcd.com)
  • 9. First File? 1. ? 2. Makefile 3. LICENSE 8 October 2013 University of Virginia cs4414 8 Can we start writing some code please!?!?? (Note: you are not required to use a permissive LICENSE for code you write for this class, but anything you derive from our starting code must follow the LICENSE provided there.)
  • 10. First File: README.md 1. README.md 2. Makefile 3. LICENSE 8 October 2013 University of Virginia cs4414 9 Now, start writing code… (or documentation!) You may think this seems silly for small programs. But, every big, complex program started out as a small one. A few minutes setting up your repo will be worth it in the long run.
  • 11. 8 October 2013 University of Virginia cs4414 10 “You can use them freely (with some kind of link) in not-for-profit publications, and I’m also okay with people reprinting occasional comics (with clear attribution) in publications like books, blogs, newsletters, and presentations. If you’re not sure whether your use is noncommercial, feel free to email me and ask (if you’re not sure, it's probably okay).” (Detailed explanation of xkcd license.) Synchronization
  • 12. Scheduling Meetings Bob Alice Colleen“When can you meet Friday?” “When can you meet Friday?” “11am or 3pm” “9am or 11am” “11am it is” “11am it is.” Reserves 11am for meeting Reserves 11am for meeting Selects and reserves 11am
  • 13. Partial Ordering of Events • Sequential programs give us a total ordering of events: everything happens in a determined (sequential) order • Concurrent programs give us a partial ordering of events: we know some things happen before other things, but other orderings are undetermined
  • 14. Bob Alice Colleen“When can you meet Friday?” “When can you meet Friday?” “11am or 3pm” “9am or 11am” “11am it is” “11am it is.” Reserves 11am for meeting Reserves 11am for meeting Selects and reserves 11am A1 A2 B1 C1 A3 A4 A5 B2 C2
  • 15. Race Condition • Race Condition: Behavior of a program depends on order of events • Data race: two threads read and write shared data in a way such that ordering of events changes resulting state • Time-of-check-to-time-of-use: thread 1 checks some property, thread 2 modifies it, thread 1 does something based on the out- of-date check 8 October 2013 University of Virginia cs4414 14
  • 16. Bob Alice Colleen“When can you meet Friday?” “When can you meet Friday?” “11am or 3pm” “9am or 11am” “11am it is” “11am it is.” Reserves 11am for meeting Reserves 11am for meeting Selects and reserves 11am A1 A2 B1 C1 A3 A4 A5 B2 C2 Any race conditions here?
  • 17. Bob Alice Colleen“When can you meet Friday?” “When can you meet Friday?” “11am or 3pm” “9am or 11am” “11am it is” “11am it is.” Reserves 11am Reserves 11am Selects and reserves 11am A1 A2 B1 C1 A3 A4 A5 B2 C2 Dave “When can you meet Friday?” “9am or 11am” D2 “Ok, 11am.” Selects and reserves 11am
  • 18. Preventing Data Races • Use locks to impose ordering constraints • After responding to Alice, Coleen reserves all the times in response until she hears back
  • 19. Bob Alice Colleen“When can you meet Friday?” “When can you meet Friday?” “11am or 3pm” “9am” Reserves 11am A1 A2 B1 C1 Dave “When can you meet Friday?” “9am or 11am” D2 “Ok, 11am.” Selects and reserves 11am While Colleen’s calendar is locked, cannot allow Alice to read it!
  • 20. Bob Alice Colleen“When can you meet Friday?” “When can you meet Friday?” “11am or 3pm” A1 A2 B1 Dave “When can you meet Friday?” “9am or 11am” “Bob, w hen can you meet Friday?”
  • 21. Deadlock Deadlock: A group of threads are stuck because of resource dependencies 8 October 2013 University of Virginia cs4414 20 Thread A Resource 1 Resource 2 Thread B Locks Locks Needs Needs
  • 22. Why are threads hard? • Too few ordering constraints: race conditions • Too many ordering constraints: deadlocks • Hard/impossible to reason modularly If an object is accessible to multiple threads, need to think about what any of those threads could do at any time! • Testing is even more impossible than it is for sequential code: even if you test all the inputs, don’t know it will work if threads run in different order Rust makes safe threads easy(er)!
  • 23. Safe Rust Code Is it possible to have a data race condition? Is it possible to have a deadlock? 8 October 2013 University of Virginia cs4414 22
  • 24. Multi-Rustic Map-Reduce 8 October 2013 University of Virginia cs4414 23 Alexander Lamana Jasdev Singh Nishant Shukla William Thomason
  • 25. Problem Set 3: Zhtta web server 8 October 2013 University of Virginia cs4414 24
  • 26. 8 October 2013 University of Virginia cs4414 25 Yesterday’s Top Story
  • 27. 8 October 2013 University of Virginia cs4414 26
  • 28. 8 October 2013 University of Virginia cs4414 27 “In some cases, the Web site does not recognize users who established accounts before Oct. 1, when the online marketplaces opened for consumers to shop for insurance. Other users are prevented from establishing accounts. Some who successfully established a marketplace account received an e-mail asking them to verify their e-mail addresses, but the link provided did not work.” (NYT article) Race condition, deadlock, or general crappiness?
  • 29. Is it unusual for a web service to face 1M requests in a day? 8 October 2013 University of Virginia cs4414 28 reddit.com Google: over 5 Billion searches per day (average for 2012)
  • 30. 8 October 2013 University of Virginia cs4414 29 “But because of the initial failures, other parts of the complex system have yet to be proved under the intense strain of real-world conditions. And outside experts said that White House officials should have spent more time tending to the computer code and technology of the Web site, rather than recruiting Hollywood celebrities to promote it.” … Those comments echoed similar criticism on sites across the Internet, where Web designers and developers speculated about the reasons for the ongoing problems at the Web site, healthcare.gov. One discussion on the popular Web site reddit.com was titled “How not to optimize a website.”
  • 31. 8 October 2013 University of Virginia cs4414 30 White House officials declined to identify the private contractors who had built the account creation function, citing a decision to keep that information private. They said the contractors had moved that part of the new system to beefed-up hardware and were busy rewriting the software code to make it more robust and efficient. In the past week, wait times have dropped by half, officials said. Officials said they had also added staff members at call centers to provide customers an alternative to the online system. The Web site currently says that people “in a hurry” can apply faster at a government call center using a toll-free telephone number, (800) 318-2596. But an operator at the call center said Monday that he could not help because he, too, was “experiencing technical difficulties with the Web site.”
  • 32. Ouch…what was today’s top story? 8 October 2013 University of Virginia cs4414 31
  • 33. 8 October 2013 University of Virginia cs4414 32
  • 34. NSA Meltdown 8 October 2013 University of Virginia cs4414 33 “Experts estimate the new center in Utah can store data by the exabyte or zettabyte.”
  • 35. z vs. Z 8 October 2013 University of Virginia cs4414 34 Minimum energy needed to flip one bit (Landauer limit) ≈ kT ln 2 ≈ 2.8 zJ (zeptoJoules) Energy NSA would need to brute-force AES 128- bit keys ≈ 1.0 ZJ
  • 36. 8 October 2013 University of Virginia cs4414 35
  • 37. 8 October 2013 University of Virginia cs4414 36
  • 38. Problem Set 3 • Your Zhtta server will probably not actually be 1042 times better than zhttpo! • Putting the Z in zhtta: – A safe shared counter – Flexible scheduling (including prioritizing Charlottesville requests) – Smart page caching – Server-side gash scripts – Your interesting extensions and performance improvements 8 October 2013 University of Virginia cs4414 37 PS3 is due Monday, 28 October
  • 39. Finding PS3 Teams 8 October 2013 University of Virginia cs4414 38 Rule: team of 2 or 3, cannot be the exact same team you had for PS2 (teams of 3 can include a PS2 team) Team A Team B Team C Challenging asynchronous resource contention problem with many possible deadlocks! Try to solve it synchronously now.