Go4 CHEP 2001 Multithreaded Inter-Task Communication with ROOT - GSI Online Offline Object Oriented Go4 Multithreaded Inter-Task Communication with ROOT - writing non-blocking GUIs J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel 04.09.01 Go4 - http://go4.gsi.de
Contents Go4: Software layers and architecture Go4 Requirements Multithreading (threadmanager library) Inter task communication (taskhandler library) Example: GUI task and analysis task GUI implemetation with ROOT-Qt Interface Demo (movie) Summary 04.09.01 Go4 - http://go4.gsi.de
ROOT Framework Go4 Package Layers Go4 Event Analysis Loop (Client) Go4 GUI (Server) Go4TaskHandler Qt Library Go4ThreadManager Interface TThread ROOT Framework 04.09.01 Go4 - http://go4.gsi.de
On-line Analysis with non blocking GUI Requirements of Go4 On-line Analysis with non blocking GUI Analysis based on ROOT Analysis runs permanently Analysis updates graphics asynchronously GUI is never blocked GUI controls and steers analysis 04.09.01 Go4 - http://go4.gsi.de
Threadmanager library Problems to solve Multithreading necessary ROOT classes not inherently thread save lock object creation and ROOT services nonblocking GUI and analysis: different tasks Communication between tasks Threadmanager library Taskhandler library 04.09.01 Go4 - http://go4.gsi.de
Go4 Multitasking system Only one working thread per task (object creation, memory allocation, ROOT system calls) Analysis and GUI in separate tasks (non blocking GUI, continuous analysis) Communication: raw socket transport (dedicated threads with TBuffer fields in TGo4Socket) Object streaming by ROOT (working thread uses TGo4Queue methods) 04.09.01 Go4 - http://go4.gsi.de
Functional overview GUI Data Loop Display Task (Server) Drawing Thread Logging Thread Useraction queue queue queue Launch Thread Task Handler Command Thread Data Thread Status Thread Connector Thread IP Network Data Loop Command Thread Data Thread Status Thread Task Handler Two tasks with each including threads and communicating via a transport implementation Display: GUI and X timer (for repeated requests, refresh) run in the main root gApplication loop; GUI callbacks send commands to analysis; Objects (e.g. histograms) are received from analysis by update thread; logger thread receives status information. Both threads and GUI share access to same graphics (Canvas, Listbox, Buttons..) Analysis: Event Loop runs as thread, same thread also executes dynamic commands (like histogram requests) and macros; Status thread sends current analysis state; Controlled from Display by Command thread: queues commands to Event Loop; may cancel/restart eventloop thread in case of latchup; controls a timer notify waiting for TCondition, which blocks the main root gApplication loop, since this showed to affect the thread stability (no TThread::Lock in TApplication). When root system loop is needed (thread restart, macro), block timer notify is released; next time it is blocked by condition wait again. => threadsave TApplication.Run in future? queue queue queue Analysis Tasks (Client 1,2,...) Work Thread Watcher Thread 04.09.01 Go4 - http://go4.gsi.de
Go4 GUI Complex GUI Qt graphics library Rapid prototyping professional, powerful, free, tools (QtDesigner), well documented Use ROOT and Qt together! no changes to ROOT sources Go4 GUI architecture: signal-slot mechanism (both Qt and ROOT) gui singleton: registry + dispatcher (modified mediator pattern) persistent status objects per window 04.09.01 Go4 - http://go4.gsi.de
Go4 GUI: Qt-ROOT interface QApplication TApplication QROOTApplication TQApplication Qt Eventloop QApplication::Exec() QTimer ROOT Eventloop TSystem::InnerLoop() TTimer TThread QWidget QWidget TSocket other... TQROOTCanvas QWidget TCanvas TRootGuiFactory TQRootGuiFactory TCanvasImp TQCanvasImp 04.09.01 Go4 - http://go4.gsi.de
Go4 GUI: Qt-ROOT interface Follows the general ROOT GUI ABC no changes in ROOT source necessary Inheritance from ROOT base classes TQRootGuiFactory (TRootGuiFactory) Qt Factory GUI components TQCanvasImp (TCanvasImp) creates a Qt independent main window (QMainWindow) sets TQRootCanvas as a central widget TQApplication (TApplication) ROOT environment set with a Qt GUI factory Inheritance from Qt base class QRootApplication (QApplication) enable Qt evt-loop to drive Qt based GUI applications call ROOT inner loop repeatedly to enable ROOT system events 04.09.01 Go4 - http://go4.gsi.de
Qt Designer screenshot 04.09.01 Go4 - http://go4.gsi.de
Using Qt designer 04.09.01 Go4 - http://go4.gsi.de
Go4 GUI design GUISingleton registry Display command dispatcher status mediator commands Display taskhandler server IP data to analysis register (dependency) update Qt GUI Widgets Status Slots Qt GUI Widgets Status Slots Root GUI Widgets Status Slots Qt GUI Widgets Status Slots 04.09.01 Go4 - http://go4.gsi.de
ready to use for any ROOT application Summary Go4 thread manager package Go4 task handler package Go4 Qt-ROOT interface ready to use for any ROOT application Client task could be analysis framework, slow ctrl,... GUI task can use Qt graphics library Go4 analysis framework and GUI is being under development... http://go4.gsi.de 04.09.01 Go4 - http://go4.gsi.de
Go4 demo monitored histograms ROOT canvas Control panel analysis status Here comes the sun ... local objects remote objects 04.09.01 Go4 - http://go4.gsi.de
Go4 demo Initializing a remote analysis Control of analysis: run status, list object folders Monitor remote histograms continuously Get and update local object copies Working on local histograms (fit panel, save) ROOT TBrowser works in parallel Go4 Browser plots: superimpose, multiwindow 04.09.01 Go4 - http://go4.gsi.de
Go4 demo Here comes the sun ... 04.09.01 Go4 - http://go4.gsi.de
Go4 demo Here comes the sun ... 04.09.01 Go4 - http://go4.gsi.de
Go4 demo Here comes the sun ... 04.09.01 Go4 - http://go4.gsi.de
Go4 demo Here comes the sun ... 04.09.01 Go4 - http://go4.gsi.de
Go4 demo regular ROOT TBrowser, works together with Qt 04.09.01 Here comes the sun ... 04.09.01 Go4 - http://go4.gsi.de
Go4 demo Here comes the sun ... 04.09.01 Go4 - http://go4.gsi.de