chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] New egg: hopefully


From: Jörg F . Wittenberger
Subject: Re: [Chicken-users] New egg: hopefully
Date: Sun, 20 Dec 2015 18:00:06 +0100
User-agent: Mozilla/5.0 (X11; Linux armv7l; rv:38.0) Gecko/20100101 Icedove/38.4.0

Am 20.12.2015 um 15:50 schrieb Sudarshan S Chawathe:
> 
> Thanks for following up.  I hope the cause isn't something silly in my
> setup.
> 
> I ran tested with a run.scm modified as you indicated, except that I'm
> guessing you meant line 127, not 217.  (I couldn't find any obvious

Yes, 127 is correct.  ;-)

> match on line 217, so I replaced the one starting on line 127.)  The
> results are attached.  It fails the assertion:
> 
>   (assert (= call-count -3))

This, and your'e getting a different execution sequence and all.  Now
this assert used to be commented out, since it's not by definition, but
expected.

I currently do not understand why T2 is not winning the race.

Could you ignore that please for a moment (comment out).  I'm interested
in the mutex's state.

Also please insert a thread-sleep! right after those debug prints, so we
see what T2 is doing here.  Like so (first and last line unchanged):


====
       (step! "T1 done" mux2 #f (cell-ref a)))))
  ;;(assert (= call-count -3)) ;; -- not defined to be -3, but normally
  (dbg 'M1 (mutex-state mux1))
  (dbg 'M2 (mutex-state mux2))
  (thread-sleep! 1)
  (assert (= (obox-v b1) 455))
====

> 
> Regards,
> 
> -chaw
> 
>> From: address@hidden
>> Date: Sun, 20 Dec 2015 15:07:17 +0100
>> Subject: Re: [Chicken-users] New egg: hopefully
>>
>> Am 19.12.2015 um 23:31 schrieb Sudarshan S Chawathe:
>>> Thanks for the update. I see the same behavior with tests/run.scm as
>>> before: Compilation with csc is fine, but executing the resulting file
>>> 'run' gives exactly the same error as before:
>>> =
>>
>>>   Error: assertion failed: (=3D (obox-v b1) 455)
>>> =
>>
>>> (Detailed error message is same as in my earlier message.)
>>
>> Hm, that's strange.  I blindly assumed this to somehow follow from the
>> import gone wrong.
>>
>> Now I did no do much yesterday but re-run this over and over again to
>> tune the implementation.  Neither on 4.9.1 or master.
>>
>> Could you please _replace_ the let form in run.scm starting around line
>> 217 with the one below and try.  Should give me more details.
>>
>> The expected output:
>>
>> D #<thread: thread182>: also in other thread former ref is still
>> unchanged...
>> D even after commit.  (Note: tests caching of references to fields.): 9
>> T2 x cc 2 6
>> T1 x cc 2 7
>> T2 y cc 2 7
>> T2 done cc 2 65
>> T1 y cc -2 6
>> T1 done cc -2 42
>> T1 x cc -3 7
>> T1 y cc -3 65
>> T1 done cc -3 455
>> D M1: not-owned
>> D M2: not-abandoned
>> Locking 20000 op in 1530.0 ms (13.0718954248366 op/ms)
>> Optimistic 20000 op in 1324.0 ms (15.1057401812689 op/ms)
>>
>> Thanks for your help.
>>
>> /J=F6rg
>>
>> Here the more verbose test expression:
>>
>> (let ((mux1 (make-mutex 'T1)) (mux2 (make-mutex 'T2))
>>       (call-count 0))
>>   (define (step! msg mux1 mux2 val)
>>     (mutex-unlock! mux1)
>>     (if (and mux2 (> call-count 0) (< call-count 100)) (mutex-lock! mux2
>> #f #f))
>>     (if msg (format (current-error-port) "~a cc ~a ~a\n" msg call-count
>> val))
>>     val)
>>   (mutex-lock! mux1 #f #f)
>>   (mutex-lock! mux2 #f #f)
>>   (thread-start!
>>    (lambda ()
>>      (call-with-transaction
>>       (lambda (tnx)
>>      (if (>=3D call-count 0) (set! call-count (add1 call-count))
>>          (set! call-count (sub1 call-count)))
>>      (if (< call-count 100)
>>          (let ((a (obox-v-ref b2 tnx))
>>                (b (obox-v-ref b1 tnx)))
>>            ;; Normally one should never do this.  We enforce thread
>>            ;; switches during transaction.
>>            (alter!
>>             a
>>             (let* ((x (step! "T2 x" mux1 mux2 (cell-ref a)))
>>                   (y (step! "T2 y" mux1 mux2 (cell-ref b))))
>>               (+ 23 (* x y))))
>>            (step! "T2 done" mux1 #f (cell-ref a)))
>>          (step! "T2 call count exceeded" mux1 #f call-count))))
>>      (set! call-count (- call-count))))
>>   (call-with-transaction
>>    (lambda (tnx)
>>      (if (>=3D call-count 0) (set! call-count (add1 call-count))
>>        (set! call-count (sub1 call-count)))
>>      (let ((a (obox-v-ref b1 tnx))
>>         (b (obox-v-ref b2 tnx)))
>>        (alter!
>>      a
>>      (let* ((x (step! "T1 x" mux2 mux1 (cell-ref a)))
>>            (y (step! "T1 y" mux2 mux1 (cell-ref b))))
>>        (* x y)))
>>        (step! "T1 done" mux2 #f (cell-ref a)))))
>>   (assert (=3D call-count -3)) ;; -- not defined to be -3, but normally
>>   (dbg 'M1 (mutex-state mux1))
>>   (dbg 'M2 (mutex-state mux2))
>>   (assert (=3D (obox-v b1) 455))
>>   (assert (=3D (obox-v b2) 65)))
> 
> 
> 
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-users
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]