Concurrent programmin g - · PDF fileConcurrent programmin The industrial expe gxP rience....
Transcript of Concurrent programmin g - · PDF fileConcurrent programmin The industrial expe gxP rience....
Karol Ostrovský
› M.Sc. – Comenius University
› Ph.D. – Chalmers
› Post-doc – Chalmers
› System Designer – Dfind, on – Operations & Maintenance Subs
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
, Bratislava
assignment at Ericssonsystem
age 2
Karol Ostrovský
› Language skillsB i–Basic
–Pascal–C/C++–C/C++–Scheme–SmallTalkSmallTalk–Java–JR (MPD)–Haskell–Erlang
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
–OcamlLaTeX–LaTeX
–VAX assembler–TrilogyTrilogy–Ada–Agdag
age 3
The chalmers yea
› Research in static analysis oflanguageslanguages
– Type systems– Protocol analysis
› Main course responsible PPxDeveloped the course between– Developed the course between
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ars
f concurrent programming
xT2005 and 20102005 and 2010
age 4
The case of the m
The Message from
• Should you forget evercourse, please, rememp
Use the right to
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
issing slide
m this Course
rything from this mber at least this saying:y g
ool for the job.
age 5
3PPVT10 – Introduction
What does this bu
Course Goals
• Introduction to the promany computing discipy p g p◦ Operating systems◦ Distributed systemsR l ti t◦ Real‐time systems
• Appreciation of the proprogrammingp g g◦ Classic synchronisation
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
uy you?
– General
oblems common to plines:p
oblems of concurrent
n problems
age 6
9PPVT10 – Introduction
What does this bu
Course Goals
• Understanding of a range constructs for concurrent
• Ability to apply these in pproblems in concurrent pp p
• Practical knowledge of theof modern concurrent proof modern concurrent pro
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
uy you?
– Practical
of programming language programming
ractice to synchronisation rogrammingg g
e programming techniques ogramming languagesogramming languages
age 7
10PPVT10 – Introduction
what does this re
› Everything this course teache– As is– As is
› Erlang lectures – almost prod
– Applied or customised› Resource allocation› Master – slave› Timeouts, alarms
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
eally buy you?
es is used in industrial practice
duction code
age 8
The pthreads expe
› SGSN shell in CProblem: Unix signal handling› Problem: Unix signal handling
› Solution: create a separate th– My problemy p
› I never practically used pthre– My solution
› general solution based on co› general solution based on co- synchronisation, mutual e
› “translate” to pthreads
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
erience
g was insufficientg was insufficienthread for signal handling
eads before
oncurrency principlesoncurrency principlesexclusion, message passing
age 9
The general solut
Main
Shared
Main
Handler
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
tion
d data
age 10
Pthreads transla
init
Main
Mutex vlock
Maincreate
unlockHandler
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ation
destroyvariable unlock
join
age 11
Ericsson – where a
› Business Unit Networks– Development Unit IP and Broad– Development Unit IP and Broad
› Product Development Unit P- SGSN-MME
› O&M sub-system› 2G sub-system› 3G sub-systemy› ...
- GGSN-MPG- CPG- CPG- ...
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
am i?
bandbandacket Core
age 12
Mobile telecom n
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
etwork
age 13
packet core netw
› 3GPP– Defines standards (mostly proto– Defines standards (mostly proto– Interoperability is essential
› SGSN-MME– Servicing GPRS Support Node (– Mobility Management Entity (4GMobility Management Entity (4G– Control signalling
› Admission control, AuthenticM bilit i› Mobility, roaming
– Payload transport (not in 4G)
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
work
ocols)ocols)
(2G/3G)G)G)
ation
age 14
SGSN-MME – mkvi
› 3 sub-racks› 21 blades (2+19)› 2 core PowerPC› ~ 114 simultaneously running processes
› Backplane: 1Gbps
› Up to 3 MSAU
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Paage 15
SGSN-MME – MkViii
› 3 sub-racks› 14 blades (2+12)› 6 core Intel x86
–12 SMT threads total› ~ 432 simultaneously
irunning processes
B k l 1 10Gb› Backplane: 1 or 10Gbps
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Paage 16
SGSN-MME – archit
NCB FSNCBNCB FSNCB
AP APAP AP
DP DP
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
tecture sketch
SB FSBSB FSB
...... APAP
... DP
age 17
Sieve of Eratosth
Architec
• Onenums One
filter1 filter2filter1 filter2
outpprint
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
enes
cture
• N+1 pipeline channelse shared output channele shared output channel
filterNfilterN
eatput
age 18
46PPVT10 – Message Passing
pipeline of proces
NCNC
AP_1 AP_2
logLOG
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
g
sses
CBCB
AP_N
gging
age 19
gg g
Typical concurre
› One mobile – one process (re– Isolation– Isolation– Synchronisation only with resou
› Central resources– Resource allocator– Master/coordinator – slave/work
› Transaction handler› Transaction handler› Node management
– Configuration management– Fault management (e.g. barrier – Timeouts, alarms (e.g. heartbea
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ncy patterns
eplicated worker)
rces
ker
sync. during start-up)at)
age 20
SGSN-MME
› A huge version of the assignm– The pub SGSN MME node– The pub – SGSN-MME node– Customers – mobile phones– The landlord – NCB– The assistant – node manageme– The tables – system resources
› Extension of the assignment– SGSN-MME can run in a pool –– Operations & Maintenance?
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ment 2
ent
multiple-bars?
age 21
Operations & Main
› Configuration management– Maintaining working and consist– Maintaining working and consist
› Logging– “Black box” (flight data recorder)
› Fault management– Alarm handling
P f t› Performance management– Gathering statistics– Monitoring health
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ntenance
tent settingstent settings
)
age 22
Haskell patterns
› Good– Keeps pure and side effecting c– Keeps pure and side-effecting c
› Good separation of concerns› Improved compositionality› Possible performance gain
– Gather writes together and writetransactions:
› 1 item write costs 10› 10 items write is not 100 but
› Bad› Bad– In rapid prototyping it can presen– So, it is good that Erlang does n
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
– monads
omputations apartomputations aparts
e to DB once – amortise the cost of
only 20!
nt a big hurdle to jump overnot have static types
age 23
OO-design pattern
› Factory method– Improve memory sharing– Improve memory sharing
› Object poolj p– Bounded parallelisation of algor– Overload protection
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ns
ithms – thread pool
age 24
What they do not
› Software maintenance– Software lives long– Software lives long
› Especially telecom systems (› Banking systems live even lo
– People change– Organisations change– Hardware changesg– Requirements change– Documentation often does not c
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
t teach you
(decades)onger (think COBOL)
change
age 25
Software mainten
› The developer’s challenge– Write simple (readable) and effic– Write simple (readable) and effic
1. Write a straightforward and2. Optimise later (or even bet
› Think smart but do not over-oOptimisations complicate mainte– Optimisations complicate mainte
› The code is often the only rely– Types can be very good docume
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
nance
cient code:cient code:d working solution firsttter skip this step)
optimiseenanceenance
iable documententation
age 26
Synthesis and ana
› Emphasis on synthesis so far– Software development– Software development
› Perhaps 30% of manpower isp p– Analytical work– Do you like to break a system?
B t t ti l b “ th› But testing can also be “synth– Testing frameworks
› Quickcheck› SGSN-MME has its own
– Would you like to formally prove
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
alysis
r
s spent on testingp g
h ti l”hetical”
e the system correct?
age 27
Erlang in practic
› Well suited for– Control handling of telecom traff– Control handling of telecom traff– Application layer (OSI model) ap
› Web servers, etc.– Domain Specific Language – fra
› Test scripting
› Reasonably high-level (as co› Reasonably high level (as co– Good for software maintenance
› OTP – includes useful buildin– Supervisor– Generic server– Finite state machine
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
e – pros
ficficpplications
amework
mpared to for example C)mpared to for example C)
g blocks
age 28
Erlang in practic
› Hard to find good Erlang prog
› A bit too low-level language– Given current HW limitations on
point where the code is not porta– Raise the abstraction and provid
› Where is the type system?– A static type system of Haskell-n– But good static analysis tools ar
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
e – cons
grammers (?)
e must sometimes optimise to the pable (with the same performance)de a customisable compiler, VM
nature would be a hindrancere desperately needed
age 29
More than true
Saying
• The greatest performais when a system goes y gworking
• The only thing worse thappens all the time ishappen all the timepp
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
gs
ance improvement of all from not‐working to g
han a problem that s a problem that doesn't
age 30
54PPVT10 – Introduction
Concurrent prog
› You are finishing a very good– Provides great general/theoretic– Provides great general/theoretic– Mixed with almost production lev
› The industrial experience– It is more difficult that you expec
Good systematic approach help– Good systematic approach help– Lateral thinking is an asset
Guest Lecture PPxT VT2011 | Karol Ostrovsky | © Ericsson AB 2011 | 2011-02-21 | Pa
ramming xp
coursecal backgroundcal backgroundvel practical examples
ct, butss
age 31