|
Table of Contents
POMIntroductionPOM (Parallel Object Monitors) is a concurrency abstraction for the coordination of parallel activities over single objects and groups of objects in shared memory systems. It allows a clean separation of the coordination concern from the base application code. A POM is a monitor defining a scheduling method responsible for specifying how concurrent requests should be scheduled, possibly in parallel. A POM also defines a leaving method which is executed by each thread once it has executed a request. Such methods are essential to the proposed abstraction as it makes it possible to reuse functional code as it is, adding necessary synchronization actions externally. When a thread invokes a method on an object controlled by a POM, the thread is blocked and the invocation is reified and turned into a request object. Requests are then queued in a pending queue until the scheduling method grants them permission to execute. The scheduling method can trigger the execution of several requests; all selected requests are free to execute in parallel, and are run by the thread that originated the call. When a thread has finished the execution of a request, it has to run the leaving method before leaving the POM. Note that although requests can be executed in parallel, the scheduling and leaving methods are always executed in mutual exclusion. UsagePOM is based on Reflex and therefore Reflex should be installed and configured prior to using POM. POM can be used through direct configuration or through annotations. In both cases, the scheduler is defined in the same way. Direct configurationDirect configuration consists in explicitly using the POM API in a POM configuration class so as to create the appropriate Reflex links, hooksets and metaobjects. An example of such a configuration can be found in the SVN repository: Config.java.
The first step is to create a configuration class that extends public class Config extends POMConfig { protected void initPOM() {
The schedule("reflex.lib.pom.test.bench.pc.POMBuffer", "reflex.lib.pom.test.bench.pc.POMBufferScheduler"); }
Finally create a public static void main(String[] args) throws Throwable { LogLevel.set(LogLevel.VERBOSE); Run.main(new String[] { "-lp", Config.class.getName(), "--working-set", "[+reflex.lib.pom.**]", "reflex.lib.pom.test.bench.Main" }); } } Annotations
Another, and often easier, way to configure POM is to use annotations. In this case, the @POMSyncClass( scheduler = Scheduler.class, group = Scheduler.class, syncAll = false) public class MyClass { @POMSync(category="C1") public void foo() { ... } @POMSync public void bar() { ... } public void bar2() { ... } }
In the above example, the Scheduler definition
The scheduler is responsible for granting requests the permission to execute. A POM scheduler must extend the Example 1: a simple mutual exclusion scheduler. public class MutualExclusionSched extends POMScheduler { private boolean working = false; public void schedule() { if(!working) working = executeOldest(); } public void leave(Request req) { working = false; } }
The state of Many more examples are provided in 2007-CCPE. POM and SOM
Sequential Object Monitors, or SOM, is a concurrency abstraction similar to POM but geared towards sequential activities. Actually, a SOM is a particular case of a POM where only one request is executed at a time, and there is only one object controlled by the scheduler. POM provides the DownloadThe source code for POM is available in the SVN repository: http://pleiad.dcc.uchile.cl/svn/pom/. Publications
Loading bibtex info...
|