Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!rpi!image.soe.clarkson.edu!news From: cline@cheetah.ece.clarkson.edu (Marshall Cline) Newsgroups: comp.lang.c++ Subject: Re: anonymous variables Message-ID: Date: 3 May 90 16:39:28 GMT References: <351@dyndata.UUCP> Sender: news@sun.soe.clarkson.edu Reply-To: cline@sun.soe.clarkson.edu (Marshall Cline) Organization: (I don't speak for the) ECE Dept, Clarkson Univ, Potsdam, NY Lines: 61 In-reply-to: dan@dyndata.UUCP's message of 3 May 90 03:36:34 GMT In article <351@dyndata.UUCP> dan@dyndata.UUCP (Dan Everhart) writes: ..... For example, here's a way to implement critical sections: > class Critical { > Critical() { ShutOffInterrupts(); } > ~Critical() { TurnOnInterrupts(); } > }; ... > { > Critical; > ... // Stuff in here runs with interrupts disabled. > } > // Interrupts snap back on when the block is exited. ... Clearly this is an effective mechanism for mutual exclusion. However it is dangerous to allow users to directly control the hardware (what if they went into an infinite loop after they shut off interrupts?). Another concern is its coarse granularity -- other solutions exist which provide finer granularity of control. For example, Ouij (the Concurrent-C++ mailing list admin -- see below for subscription info), posted the following on how mutual exclusion can be obtained on a class-by-class and member-by-member basis: | ``Capsules: A shared Memory Mechanism'' [Gehani, 1988] describes how | Concurrent C++ users could use a `capsule' to describe shared memory | constructs: facilties which Concurrent C lack since it is based on a | message passing model. In brief a capsule looks as follows: | | Capsule Foo { | int a, b; | public: | int reader(int k) { k = a;} | int writer(int k) { a = k;} | int useless(int k) { if (a == 1 && k > b) cout << "?????\n"; } | sync: | accept reader(k) suchthat (evaluation criteria) by (eval_criteria) | par: | { reader, useless* } | }; | | Capsules allow the programmer to specify a critical region and attach | synchronization conditions (using the `suchthat' and `by' clauses). | The `par' section is used to specify which member functions can execute | in parallel. The * denotes that multiple instances of of a member | function can execute. For those interested in further discussion, send a subscription request to the Concurrent-C++ mailing list's request server: either: info-ccc-request@xurilka.uucp or: ..!uunet!xurilka!info-ccc-request Marshall -- =============================================================================== Marshall Cline/ECE Department/Clarkson University/Potsdam NY 13676/315-268-3868 cline@sun.soe.clarkson.edu, bitnet: BH0W@CLUTX, uunet!clutx.clarkson.edu!bh0w Career search in progress: ECE faculty. Research oriented. Will send vita. ===============================================================================