50 likes | 161 Views
Overview and Discussion of Lab 2 Design. Expand the work from a single scene to entire play I.e., process a sequence of scene configuration files Some threads will perform parts from the current scene Other threads will be loading parts for the next scene
E N D
Overview and Discussion of Lab 2 Design • Expand the work from a single scene to entire play • I.e., process a sequence of scene configuration files • Some threads will perform parts from the current scene • Other threads will be loading parts for the next scene • A director thread/role will coordinate all those activities • Extend concurrency architecture from monitor object to thread pools using HSHA and/or LF patterns • Some or all roles may bind to a specific thread or vice versa (HSHA) or threads may take turns playing roles (LF) • Lab 3 will add distribution and service configuration • Thread pools on different machines will be coordinated • May leverage lab 2 thread architecture (think ahead) • Support reconfiguration on-the-fly (states of operations)
From A Scene to a Play (HSHA version) • 3 main activities • Loading parts • Reciting lines • Coordination • Play and players • As in lab 1 • Thread pool (new) • After completing a part, return to pool • Director (new) • Recruits threads from pool to load and perform parts Director [act ii scene 1] [act ii scene 2] King P K Polonius R Q P R Queen R G Reynaldo P K Rosencrantz R Q P G Guildenstern R Q P R P R P
From One Scene to the Next (LF version) • When part ends • Thread could go fetch its own work • But needs to know what to do next • Still want scenes encapsulated • Director as a role • Threads could be “self-directed” • I.e., look up next task (become the director) rather than wait for a cue Director [act ii scene 1] [act ii scene 2] King P K Polonius R Q P R Queen R G Reynaldo P K Rosencrantz R Q P G Guildenstern R Q P R P R P
Key Design Considerations • Whether to use HSHA or LF • Think about what benefits and risks are involved • E.g., design/debugging complexity vs. performance vs. … • How to relate short- and long-running activities • E.g., loading a part from a file while other threads are reciting lines, synchronizing on condition variable, returning to the thread pool, taking on a new role, … • Design decisions are again largely yours to make • If the specification differs from what you think should be done, please ask about and/or suggest new ideas • If it’s a reasonable alternative, I’ll approve it in advance • Take notes as you go, write up design in your lab report
Some Suggestions • Evolve (and debug) your solution incrementally • Start with as much of lab 1 as is working well • Add and test thread pool semantics for a single scene • Add and test director coordination for a single scene • Add and test director coordination for multiple scenes • Add and test advanced features (leader election, barriers to restrict migration of threads between scenes, etc.) • Please start early so I can be of the most help in answering questions, discussing ideas, etc. • Where to put the threads will require key choices • Those choices may affect how rest of design evolves • Some choices may need to be revisited (modularity helps)