473,715 Members | 5,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ne wChild)" runs asynchronously,
whereas doing "so.children.ap pend(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.getNextChu nk)

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(obje ct,
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.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Aug 26 '05 #1
0 1473

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

Similar topics

12
2568
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 types for variables, parameters and function return values). I know there was a "types SIG" which introduced several proposals, but it expired quite a while ago, and I was wondering whether whether some consensus has been reached on the subject...
49
3109
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 (http://boo.codehaus.org/) is a different language, but I like its "as" instead of ":" and "->", to have: def min(a as iterable(T)) as T: Instead of:
1
2528
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 information feed from it. My app is compiled under Micro$oft VS.NET 2003 with option /MT to statically link in the C runtime libraries msvcrt.lib etc. My app has to store information from the server and answer requests from many remote clients. These...
8
3686
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 static; if the input file contained more than entries, tough. This time I want to do it right - use a dynamic array that increases in size with each word read from the file. A few test programs that make use of **List and realloc( List, blah...
2
1868
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 static methods are dangerous in ASP.NET because ASP.NET applications are multi thread applications. I use methods like that: CustData cd = (new BLL.CustSystem()).GetCustomer(custid); (new BLL.CustSystem()).UpdateCustomer(cd); ......
74
5063
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 Static member 'ClassInCS.ABC.MyInt' cannot be accessed with an instance reference; qualify it with a type name
44
2857
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 MS? http://media.rubyonrails.org/presentations/pursuitofbeauty.pdf
11
3047
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
2886
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
8823
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9198
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.