realbasic-nug
[Top] [All Lists]

Re: Preemptive threading

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Preemptive threading
From: Jonathan Johnson <jon at alacatialabs dot com>
Date: Wed, 30 Jan 2008 16:07:32 -0600
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <1ibjwun dot rraqoxob52fxM%realbasiclists at monkeybreadsoftware dot de>
On Jan 30, 2008, at 3:57 PM, Christian Schmitz wrote:

>> If both threads do it at once, it is possible for the REALbasic  
>> runtime to
>> get in a situation where the reference count was only incremented  
>> once,
>> because it isn't thread-safe.
>
> That is no problem if you use LockRuntime UnlockRuntime.

Even calling LockRuntime and UnlockRuntime will cause the ThreadMBS  
instance to be locked and then unlocked twice. Disassemble an app to  
verify it.

>> The REALbasic runtime *needs* thread-safety. Until it's thread-safe,
>> the only safe methods you can write in REALbasic code are strictly
>> mathematical functions in global modules that don't refer to any
>> objects or strings.
>
> I know. Actual you have no big problems if you keep your reference
> counts unchanged while the thread is working.

Right, but that's impossible. Object locking and unlocking happens all  
over the place. Disassemble an RB app and look at it. Even the act of  
calling your preemptive thread's Run event causes the thread to be  
locked on entry, and unlocked on return.

I'm just saying it's a recipe for horrible, hard to detect disasters  
until RS adds at least some thread safety to locking and unlocking.  
Subtle things can cause a temporary reference to be stored, and I  
don't think there's a safe way to do it today unless you do it through  
declares, call back directly into a module method, and avoid objects  
entirely.

-Jon



-- 
Jonathan Johnson
President
Alacatia Labs, Inc.
http://www.alacatialabs.com/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


From  Wed 30 Jan 2008 23:27:30 +0100
Return-Path: <realbasic-nug-bounces at lists dot realsoftware dot com>
X-Original-To: listarchive at realsoftware dot com
Delivered-To: listarchive at realsoftware dot com
Received: by xmail.realsoftware.com (Postfix, from userid 1037)
        id 729B359E6BB4; Wed, 30 Jan 2008 14:27:43 -0800 (PST)
X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on 
        www.realsoftware.com
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=4.5 tests=AWL,BAYES_00 autolearn=ham 
        version=3.1.1
Received: from lists.realsoftware.com (m.realsoftware.com [66.116.103.65])
        by xmail.realsoftware.com (Postfix) with ESMTP id 0458159E6B9A;
        Wed, 30 Jan 2008 14:27:37 -0800 (PST)
Received: from m.realsoftware.com (localhost [127.0.0.1])
        by lists.realsoftware.com (Postfix) with ESMTP id 5F1E0DC2724;
        Wed, 30 Jan 2008 16:27:34 -0600 (CST)
X-Original-To: realbasic-nug at lists dot realsoftware dot com
Delivered-To: realbasic-nug at lists dot realsoftware dot com
Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de
        [80.67.29.7])
        by lists.realsoftware.com (Postfix) with ESMTP id 0FBB5DC2719
        for <realbasic-nug at lists dot realsoftware dot com>;
        Wed, 30 Jan 2008 16:27:32 -0600 (CST)
Received: from [84.175.91.12] (helo=[192.168.1.80])
        by smtprelay07.ispgateway.de with esmtpa (Exim 4.68)
        (envelope-from <realbasiclists at monkeybreadsoftware dot de>)
        id 1JKLP0-0002ue-Pa for realbasic-nug at lists dot realsoftware dot com;
        Wed, 30 Jan 2008 23:27:30 +0100
To: realbasic-nug at lists dot realsoftware dot com (REALbasic NUG)
In-Reply-To: <A70007F0-E601-424E-8E0A-365F608BD714 at alacatialabs dot com>
Subject: Re: Preemptive threading
From: realbasiclists at monkeybreadsoftware dot de (Christian Schmitz)
Date: Wed, 30 Jan 2008 23:27:30 +0100
Message-ID: <1ibjy03 dot 81gypi18b74atM%realbasiclists at monkeybreadsoftware 
dot de>
MIME-Version: 1.0
User-Agent: MacSOUP/D-2.8.2 (Mac OS X version 10.5.1 (x86))
X-Df-Sender: 363246
X-BeenThere: realbasic-nug at lists dot realsoftware dot com
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Sender: realbasic-nug-bounces at lists dot realsoftware dot com
Errors-To: realbasic-nug-bounces at lists dot realsoftware dot com

Jonathan Johnson <jon at alacatialabs dot com> wrote:

> Even calling LockRuntime and UnlockRuntime will cause the ThreadMBS  =

> instance to be locked and then unlocked twice. Disassemble an app to
> verify it.

That are static methods.

> I'm just saying it's a recipe for horrible, hard to detect disasters until
> RS adds at least some thread safety to locking and unlocking. Subtle
> things can cause a temporary reference to be stored, and I don't think
> there's a safe way to do it today unless you do it through declares, call
> back directly into a module method, and avoid objects entirely.

Well, some things are difficult, but it works fairly nice here.

We will see how nice it will work.

Gru=DF
Christian

-- =

Over 900 classes with 18000 functions in one REALbasic plug-in. =

The Monkeybread Software Realbasic Plugin v8.0. =


<http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>