OOD Design of Processes 2 Server Patterns ITV Modelbased Analysis and Design of Embedded Software Anders P. Ravn & Arne Skou Aalborg University February 2011
Simple Generic Architecture OAD p.196 «component» Interface «component» Model «component» UserInterface «component» SubsystemInterface «component» Platform «component» OS «component» FileSystem «component» Function...
The Task to Solve Assume: Design is already mapped to Sequential Programs (Classes) «component» QQQQQQQQQ «component» MMMMMMMMM Provide: Architecture mapped to Concurrent Programs on a Platform «component» Interface «component» UserInterface «component» SystemInterface «component» Model «component» Function «component» Platform «component» OS «component» FileSystem
Platform Characteristics onenone Ordinary c++, c threadsshared objects Java, CORBA, SYMBION? tasksasynch. message Posix, RTOS ProcessesSynchronizationExample
Concurrent Access «component» Interface «component» UserInterface «component» SystemInterface «component» Model «component» Platform «component» OS «component» FileSystem «component» Function «interface» Application read(Key) : ReadData update(UpdateData) compute(Mode) : Result attach(SignalHandler) «synchronized» Wrapper... read(Key k) : ReadData update(UpdatDatae u) compute(Mode m) : Result attach(SignalHandler sh) + concurrent access implements
Implementation (Java) synchronized class Wrapper {... public void update(Update u)... } }; «synchronized» Wrapper... update(Update u) class Wrapper {... public synchronized void update(Update u)... } }; class Wrapper {... public void update(Update u)... synchronized{... } } };
Server Pattern: Interface Component «component» Interface «component» UserInterface «component» SystemInterface «component» Model «component» Platform «component» OS «component» FileSystem «component» Function «interface» Application read(Key) : ReadData update(UpdateData) compute(Mode) : Result attach(SignalHandler) «synchronized» ServerPort... read(Key k) : ReadData update(UpdatDatae u) compute(Mode m) : Result attach(SignalHandler sh) IFunction from Function Server + concurrent access
Server Behaviour Server wait op 2 op 1 op 3 complete
Server Pattern: Function Component «component» Interface «component» UserInterface «component» SystemInterface «component» Model «component» Function «component» Platform «component» OS «component» FileSystem «interface» IFunction read(Key) : ReadData update(UpdateData) compute(Mode) : Result attach(SignalHandler) IModel from Model... read(Key k) : ReadData update(UpdateData u) compute(Mode m) : Result attach(Signalhandler sh) «synchronized» FServerPort FServer
And so on for a Model Server... «component» Interface «component» UserInterface «component» SystemInterface «component» Model «component» Function «component» Platform «component» OS «component» FileSystem
- more code - complex code + short response times + concurrency Server Call Pattern - update p:FServenPorthp: ServerPortm: Model update(u) read(k) put(d) cf. OAD p h: Server wait(op) update(u) wait(op) f: FServer wait(op)
- more code - complex code - long response times ? RMI / RPC Server Call Pattern - read fp:FServerPorthp: ServerPortm: Model read(k) cf. OAD p h: Server wait(op) read(k) wait(op) f: FServer wait(op) return(d)
Exercises 1.Adapt your System (Model Component) to be a Server. 2.How many Client processes would you support concurrently?