473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Static vs. dynamic checking for support of concurrent programming

The recent thread on threads caused me to reread the formal definition
of SCOOP, and I noticed something I hadn't really impressed me the
first time around: it's using staticly checkable rules to help ensure
correct behavior in a concurrent environment.

That's impressive. That's *really* impressive. I know of no other
language that does that - though they probably exist. I'd be
interested in references to them.

Normally, I think of static checking as something that's not critical,
as a good test suite will cause exceptions on the things that static
checking catches. But concurrency errors are a completely different
class of critter entirely, and generally result in really nasty
runtime errors.

Which leads to the question - what would it take to get Python to
throw exceptions in the cases where a compiler implementing SCOOP will
emit an error message? There's two reasons for looking into this. One,
wanting to continue to believe that static checking doesn't really buy
anything. Two, wanting Python to have more powerful and robust tools
for dealing with threads. If these can be made to work, then they're a
candidate for addition. If not, then we need to look elsewhere. I'm
not going to worry about how the semantics would be implemented at
this point - I'm more interested in whether the static rules can be
enforced in a dynamic environment.

First, the rules. These are greatly simplified and mangled to describe
a hypothetical Python-like language. If you want to see the formald
definitions yourself, you can find them at <URL:
http://archive.eiffel.com/doc/manual...NCURRENCY.html
.


The new feature: a variable can be marked as "separate". This means
the object it refers to is running on a different thread, and changes
the semantics of accessing it in various ways:

First, invoking a method and ignoring it's return value is run
asynchronously. Likewise, an assigment to an attribute is run
asynchronously. I'm going to call such actions a "command". Commands
are queued by the object in question, and are guaranteed to run in the
order they appear in the code. The execution order of the commands
with respect to purely thread-local statements or commands on other
separate objects is not guaranteed.

Reading the value of an attribute is a synchronization point. All
commands on the object will be execute before you are allowed to read
the value of the attribute, and no following commands on the object
will execute before the value is read.

Note that this makes the Law of Demeter something your really want to
pay attention to. Doing "so.addChild(newChild)" runs asynchronously,
whereas doing "so.children.append(newChild)" causes a read of
so.children, which will synchronize the object, then an update of
children.

Now, the constraints:

1) Any object assigned to a separate variable must really be
separate. This applies to all the ways you can do an assignment.

2) The invocation of a command on a separate objects is only legal if
the separate object is a formal argument of the enclosing
function/method.

The first one seems trivial, but avoids some nasty bugs. For instance,
if you have a list of separate objects and you want to divide a
workload up among them, you'd do something like:

def divide(self, work, workers):
for worker in workers:
self.startWork(worker, work.getNextChunk)

def startWork(self, separate worker, chunk):
worker.process(chunk)
Adding a deceleration seems to the the only way to handle this in
Python. It's basically an assertion isinstance(object,
Separate). startWork should throw an exception if it's called with an
object that isn't separate.

What happens if you call a routine with a separate object and the
routine doesn't expect one? That's almost certainly bad - most
functions expect all their statements to be executed in order. Does
solving this requrie a check on every argument passed to a function to
verify that it's not separate?

The second rule is how locking is handled. If you invoke a function
with one or more separate objects, the language processor waits until
it has the locks on all the separate objects before running the body
of the routine. This means that locking order when you need multiple
locks is determined by the language processor, not the programmer, so
you've eliminated locking order errors as a source of deadlocks.

If you don't declare separate objects, then this would seem to require
that every command be checked to see if it's on a separate object, and
if so throw an exception if the object isn't a formal argument to the
enclosing routine. If you have declarations and enforce them, you can
limit the checks to objects declared separate.

These solutions aren't very dynamic. Can anyone see how to do this
without having to declare separate variables as such?

Thanks,
<mike
--
MIKE Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Aug 26 '05 #1
0 1461

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Michael Muller | last post by:
Is there currently any plan to introduce static typing in any future version of Python? (I'm not entirely sure that "static typing" is the right term: what I'm talking about is the declaration of...
49
by: bearophileHUGS | last post by:
Adding Optional Static Typing to Python looks like a quite complex thing, but useful too: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 I have just a couple of notes: Boo...
1
by: John S Dalzell | last post by:
Hi, I have a C++ app which needs to work with a server on a remote machine. The manufacturer has given us a set of DLL's which provide API calls to send requests to the server and receive an...
8
by: Peter B. Steiger | last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C is a simple word game that involves stringing together random lists of words. In the Pascal version the whole array was...
2
by: Åženol Akbulak | last post by:
Hi; I am developing an 3 tiered application. And my user interface is an ASP.NET web application. My methods in BLL only uses own parameters and DAL. Now my methods are not static. I heard that...
74
by: Mark | last post by:
Hello Friends Please check the code below. One in C# and other in VB .Net In C# I am not able to access a static property by an instance variable, but in VB I can do it easily. The Error is ...
44
by: John A. Bailo | last post by:
Dr. Dobbs has a /glowing/ article on Ruby on Rails this month. What do you guys think? Can it replace .net, php and java? And be the Open Source OOP web solution that is not bound to Sun or...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
8
by: crjjrc | last post by:
Hi, I've got a base class and some derived classes that look something like this: class Base { public: int getType() { return type; } private: static const int type = 0; };
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.