Lisp HUG Maillist Archive

Stress test failure with threads

I seem to have found a bug in LW-6.0 (Personal Edition), however I am
reluctant to file a report since LW-6.1 Personal Edition has not been
released yet. For my own purposes I'd like to know if it's been fixed.

The RUN function below eventually hangs on my Linux machine, typically
within 100 to 3000 iterations. I am certain it's not due to the
Personal Edition memory limit since I can interrupt (SLIME C-c-c)
after the hang occurs and re-run it.

(defun test (thread-count)
  (let ((from-threads (mp:make-semaphore))
        (to-threads   (mp:make-semaphore)))
    (loop repeat thread-count
       do (mp:process-run-function
           "test" nil (lambda ()
                        (mp:semaphore-acquire to-threads)
                        (mp:semaphore-release from-threads))))
    (loop repeat thread-count
       do (mp:semaphore-release to-threads))
    (loop repeat thread-count
       do (mp:semaphore-acquire from-threads))))

(defun run ()
  (loop
     (test 16)
     (format t ".")))


* It does not hang when a semaphore is removed.

* The probability of hanging increases as thread-count increases.

* Also hangs when semaphores are replaced with blocking queues
  implemented with condition variables.

* Also hangs when the FORMAT call is removed.

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Stress test failure with threads


I can confirm this bug does not exist under LW 6.1 on OS X.   The test below runs indefinitely without hanging even with high thread counts as high as 128.   

On Jun 4, 2012, at 2:59 PM, James M. Lawrence wrote:

> 
> I seem to have found a bug in LW-6.0 (Personal Edition), however I am
> reluctant to file a report since LW-6.1 Personal Edition has not been
> released yet. For my own purposes I'd like to know if it's been fixed.
> 
> The RUN function below eventually hangs on my Linux machine, typically
> within 100 to 3000 iterations. I am certain it's not due to the
> Personal Edition memory limit since I can interrupt (SLIME C-c-c)
> after the hang occurs and re-run it.
> 
> (defun test (thread-count)
>  (let ((from-threads (mp:make-semaphore))
>        (to-threads   (mp:make-semaphore)))
>    (loop repeat thread-count
>       do (mp:process-run-function
>           "test" nil (lambda ()
>                        (mp:semaphore-acquire to-threads)
>                        (mp:semaphore-release from-threads))))
>    (loop repeat thread-count
>       do (mp:semaphore-release to-threads))
>    (loop repeat thread-count
>       do (mp:semaphore-acquire from-threads))))
> 
> (defun run ()
>  (loop
>     (test 16)
>     (format t ".")))
> 
> 
> * It does not hang when a semaphore is removed.
> 
> * The probability of hanging increases as thread-count increases.
> 
> * Also hangs when semaphores are replaced with blocking queues
>  implemented with condition variables.
> 
> * Also hangs when the FORMAT call is removed.
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
> 

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


RE: Stress test failure with threads

LW6.1 on Linux works normal as well, but LW6.0 Linux enterprise fails really hard...

I have similar test with 2 semaphores which emulate MVar and it behaves the same way as this test.

Cheers
Ruslan Abdulkhalikov

-----Original Message-----
From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of Gene Diveglia
Sent: Tuesday, 5 June 2012 4:59 AM
To: lisp-hug@lispworks.com
Subject: Re: Stress test failure with threads



I can confirm this bug does not exist under LW 6.1 on OS X.   The test below runs indefinitely without hanging even with high thread counts as high as 128.

On Jun 4, 2012, at 2:59 PM, James M. Lawrence wrote:

>
> I seem to have found a bug in LW-6.0 (Personal Edition), however I am
> reluctant to file a report since LW-6.1 Personal Edition has not been
> released yet. For my own purposes I'd like to know if it's been fixed.
>
> The RUN function below eventually hangs on my Linux machine, typically
> within 100 to 3000 iterations. I am certain it's not due to the
> Personal Edition memory limit since I can interrupt (SLIME C-c-c)
> after the hang occurs and re-run it.
>
> (defun test (thread-count)
>  (let ((from-threads (mp:make-semaphore))
>        (to-threads   (mp:make-semaphore)))
>    (loop repeat thread-count
>       do (mp:process-run-function
>           "test" nil (lambda ()
>                        (mp:semaphore-acquire to-threads)
>                        (mp:semaphore-release from-threads))))
>    (loop repeat thread-count
>       do (mp:semaphore-release to-threads))
>    (loop repeat thread-count
>       do (mp:semaphore-acquire from-threads))))
>
> (defun run ()
>  (loop
>     (test 16)
>     (format t ".")))
>
>
> * It does not hang when a semaphore is removed.
>
> * The probability of hanging increases as thread-count increases.
>
> * Also hangs when semaphores are replaced with blocking queues
>  implemented with condition variables.
>
> * Also hangs when the FORMAT call is removed.
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html



________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Stress test failure with threads

Unable to parse email body. Email id is 11616

Re: Stress test failure with threads

On Thu, Jun 7, 2012 at 10:27 AM, Martin Simmons <martin@lispworks.com> wrote:
> Yes, this is a bug in the LispWorks 6.0 implementation of semaphores.  It is
> fixed in LispWorks 6.1.

Thanks for the official word.

>> * Also hangs when semaphores are replaced with blocking queues
>>   implemented with condition variables.
>
> Please post the code for this, because condition variables don't have the same
> bug AFAIK.

For simplicity I've replaced the queue with a homemade semaphore. The
following hung between 500 and 17000 iterations in the course of five
runs.

(defstruct sema
  (count 0)
  (lock (mp:make-lock :recursivep nil))
  (cvar (mp:make-condition-variable)))

(defun inc-sema (sema)
  (mp:with-lock ((sema-lock sema))
    (incf (sema-count sema))
    (mp:condition-variable-signal (sema-cvar sema))))

(defun dec-sema (sema)
  (mp:with-lock ((sema-lock sema))
    (loop (cond ((plusp (sema-count sema))
                 (decf (sema-count sema))
                 (return))
                (t
                 (mp:condition-variable-wait
                  (sema-cvar sema) (sema-lock sema)))))))

(defun test (thread-count)
  (let ((from-threads (make-sema))
        (to-threads   (make-sema)))
    (loop repeat thread-count
       do (mp:process-run-function
           "test" nil (lambda ()
                        (dec-sema to-threads)
                        (inc-sema from-threads))))
    (loop repeat thread-count
       do (inc-sema to-threads))
    (loop repeat thread-count
       do (dec-sema from-threads))))

(defun run ()
  (loop
     (test 16)
     (format t ".")))

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


RE: Stress test failure with threads

James,

your test seems to work on LW6.1 Linux Ent...

Cheers
Rus

-----Original Message-----
From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of James M. Lawrence
Sent: Friday, 8 June 2012 2:46 AM
To: lisp-hug@lispworks.com
Subject: Re: Stress test failure with threads


On Thu, Jun 7, 2012 at 10:27 AM, Martin Simmons <martin@lispworks.com> wrote:
> Yes, this is a bug in the LispWorks 6.0 implementation of semaphores.  It is
> fixed in LispWorks 6.1.

Thanks for the official word.

>> * Also hangs when semaphores are replaced with blocking queues
>>   implemented with condition variables.
>
> Please post the code for this, because condition variables don't have the same
> bug AFAIK.

For simplicity I've replaced the queue with a homemade semaphore. The
following hung between 500 and 17000 iterations in the course of five
runs.

(defstruct sema
  (count 0)
  (lock (mp:make-lock :recursivep nil))
  (cvar (mp:make-condition-variable)))

(defun inc-sema (sema)
  (mp:with-lock ((sema-lock sema))
    (incf (sema-count sema))
    (mp:condition-variable-signal (sema-cvar sema))))

(defun dec-sema (sema)
  (mp:with-lock ((sema-lock sema))
    (loop (cond ((plusp (sema-count sema))
                 (decf (sema-count sema))
                 (return))
                (t
                 (mp:condition-variable-wait
                  (sema-cvar sema) (sema-lock sema)))))))

(defun test (thread-count)
  (let ((from-threads (make-sema))
        (to-threads   (make-sema)))
    (loop repeat thread-count
       do (mp:process-run-function
           "test" nil (lambda ()
                        (dec-sema to-threads)
                        (inc-sema from-threads))))
    (loop repeat thread-count
       do (inc-sema to-threads))
    (loop repeat thread-count
       do (dec-sema from-threads))))

(defun run ()
  (loop
     (test 16)
     (format t ".")))

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html



________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Stress test failure with threads

Thanks to all who responded. Unless I hear otherwise I'll assume it's fixed.

On Thu, Jun 7, 2012 at 9:11 PM,  <ruslan.abdulkhalikov@accenture.com> wrote:
>
> James,
>
> your test seems to work on LW6.1 Linux Ent...
>
> Cheers
> Rus
>
> -----Original Message-----
> From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of James M. Lawrence
> Sent: Friday, 8 June 2012 2:46 AM
> To: lisp-hug@lispworks.com
> Subject: Re: Stress test failure with threads
>
>
> On Thu, Jun 7, 2012 at 10:27 AM, Martin Simmons <martin@lispworks.com> wrote:
>> Yes, this is a bug in the LispWorks 6.0 implementation of semaphores.  It is
>> fixed in LispWorks 6.1.
>
> Thanks for the official word.
>
>>> * Also hangs when semaphores are replaced with blocking queues
>>>   implemented with condition variables.
>>
>> Please post the code for this, because condition variables don't have the same
>> bug AFAIK.
>
> For simplicity I've replaced the queue with a homemade semaphore. The
> following hung between 500 and 17000 iterations in the course of five
> runs.
>
> (defstruct sema
>  (count 0)
>  (lock (mp:make-lock :recursivep nil))
>  (cvar (mp:make-condition-variable)))
>
> (defun inc-sema (sema)
>  (mp:with-lock ((sema-lock sema))
>    (incf (sema-count sema))
>    (mp:condition-variable-signal (sema-cvar sema))))
>
> (defun dec-sema (sema)
>  (mp:with-lock ((sema-lock sema))
>    (loop (cond ((plusp (sema-count sema))
>                 (decf (sema-count sema))
>                 (return))
>                (t
>                 (mp:condition-variable-wait
>                  (sema-cvar sema) (sema-lock sema)))))))
>
> (defun test (thread-count)
>  (let ((from-threads (make-sema))
>        (to-threads   (make-sema)))
>    (loop repeat thread-count
>       do (mp:process-run-function
>           "test" nil (lambda ()
>                        (dec-sema to-threads)
>                        (inc-sema from-threads))))
>    (loop repeat thread-count
>       do (inc-sema to-threads))
>    (loop repeat thread-count
>       do (dec-sema from-threads))))
>
> (defun run ()
>  (loop
>     (test 16)
>     (format t ".")))
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>
>
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
> ______________________________________________________________________________________
>
> www.accenture.com
>
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Stress test failure with threads

I can't repeat the hanging with the condition variable implementation in
LispWorks 6.0 either.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/


>>>>> On Wed, 13 Jun 2012 09:57:57 -0400, James M Lawrence said:
> 
> Thanks to all who responded. Unless I hear otherwise I'll assume it's fixed.
> 
> On Thu, Jun 7, 2012 at 9:11 PM,  <ruslan.abdulkhalikov@accenture.com> wrote:
> >
> > James,
> >
> > your test seems to work on LW6.1 Linux Ent...
> >
> > Cheers
> > Rus
> >
> > -----Original Message-----
> > From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of James M. Lawrence
> > Sent: Friday, 8 June 2012 2:46 AM
> > To: lisp-hug@lispworks.com
> > Subject: Re: Stress test failure with threads
> >
> >
> > On Thu, Jun 7, 2012 at 10:27 AM, Martin Simmons <martin@lispworks.com> wrote:
> >> Yes, this is a bug in the LispWorks 6.0 implementation of semaphores..  It is
> >> fixed in LispWorks 6.1.
> >
> > Thanks for the official word.
> >
> >>> * Also hangs when semaphores are replaced with blocking queues
> >>>   implemented with condition variables.
> >>
> >> Please post the code for this, because condition variables don't have the same
> >> bug AFAIK.
> >
> > For simplicity I've replaced the queue with a homemade semaphore. The
> > following hung between 500 and 17000 iterations in the course of five
> > runs.
> >
> > (defstruct sema
> >  (count 0)
> >  (lock (mp:make-lock :recursivep nil))
> >  (cvar (mp:make-condition-variable)))
> >
> > (defun inc-sema (sema)
> >  (mp:with-lock ((sema-lock sema))
> >    (incf (sema-count sema))
> >    (mp:condition-variable-signal (sema-cvar sema))))
> >
> > (defun dec-sema (sema)
> >  (mp:with-lock ((sema-lock sema))
> >    (loop (cond ((plusp (sema-count sema))
> >                 (decf (sema-count sema))
> >                 (return))
> >                (t
> >                 (mp:condition-variable-wait
> >                  (sema-cvar sema) (sema-lock sema)))))))
> >
> > (defun test (thread-count)
> >  (let ((from-threads (make-sema))
> >        (to-threads   (make-sema)))
> >    (loop repeat thread-count
> >       do (mp:process-run-function
> >           "test" nil (lambda ()
> >                        (dec-sema to-threads)
> >                        (inc-sema from-threads))))
> >    (loop repeat thread-count
> >       do (inc-sema to-threads))
> >    (loop repeat thread-count
> >       do (dec-sema from-threads))))
> >
> > (defun run ()
> >  (loop
> >     (test 16)
> >     (format t ".")))
> >
> > _______________________________________________
> > Lisp Hug - the mailing list for LispWorks users
> > lisp-hug@lispworks.com
> > http://www.lispworks.com/support/lisp-hug.html
> >
> >
> >
> > ________________________________
> > Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
> > ______________________________________________________________________________________
> >
> > www.accenture.com
> >
> >
> > _______________________________________________
> > Lisp Hug - the mailing list for LispWorks users
> > lisp-hug@lispworks.com
> > http://www.lispworks.com/support/lisp-hug.html
> >
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Stress test failure with threads

Are you writing to confirm that it was fixed in one of the 6.0
patches, or are you looking to reproduce the hang? If the latter then
run

lispworks-personal-6-0-1-x86-linux, md5 0f836edc2f40485ffb07224485bf44e3

You need to compile the example. I just tried interpreted mode and did
not see a hang.

On Wed, Jun 13, 2012 at 10:57 AM, Martin Simmons <martin@lispworks.com> wrote:
>
> I can't repeat the hanging with the condition variable implementation in
> LispWorks 6.0 either.
>
> --
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/
>
>
>>>>>> On Wed, 13 Jun 2012 09:57:57 -0400, James M Lawrence said:
>>
>> Thanks to all who responded. Unless I hear otherwise I'll assume it's fixed.
>>
>> On Thu, Jun 7, 2012 at 9:11 PM,  <ruslan.abdulkhalikov@accenture.com> wrote:
>> >
>> > James,
>> >
>> > your test seems to work on LW6.1 Linux Ent...
>> >
>> > Cheers
>> > Rus
>> >
>> > -----Original Message-----
>> > From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of James M. Lawrence
>> > Sent: Friday, 8 June 2012 2:46 AM
>> > To: lisp-hug@lispworks.com
>> > Subject: Re: Stress test failure with threads
>> >
>> >
>> > On Thu, Jun 7, 2012 at 10:27 AM, Martin Simmons <martin@lispworks.com> wrote:
>> >> Yes, this is a bug in the LispWorks 6.0 implementation of semaphores.  It is
>> >> fixed in LispWorks 6.1.
>> >
>> > Thanks for the official word.
>> >
>> >>> * Also hangs when semaphores are replaced with blocking queues
>> >>>   implemented with condition variables.
>> >>
>> >> Please post the code for this, because condition variables don't have the same
>> >> bug AFAIK.
>> >
>> > For simplicity I've replaced the queue with a homemade semaphore. The
>> > following hung between 500 and 17000 iterations in the course of five
>> > runs.
>> >
>> > (defstruct sema
>> >  (count 0)
>> >  (lock (mp:make-lock :recursivep nil))
>> >  (cvar (mp:make-condition-variable)))
>> >
>> > (defun inc-sema (sema)
>> >  (mp:with-lock ((sema-lock sema))
>> >    (incf (sema-count sema))
>> >    (mp:condition-variable-signal (sema-cvar sema))))
>> >
>> > (defun dec-sema (sema)
>> >  (mp:with-lock ((sema-lock sema))
>> >    (loop (cond ((plusp (sema-count sema))
>> >                 (decf (sema-count sema))
>> >                 (return))
>> >                (t
>> >                 (mp:condition-variable-wait
>> >                  (sema-cvar sema) (sema-lock sema)))))))
>> >
>> > (defun test (thread-count)
>> >  (let ((from-threads (make-sema))
>> >        (to-threads   (make-sema)))
>> >    (loop repeat thread-count
>> >       do (mp:process-run-function
>> >           "test" nil (lambda ()
>> >                        (dec-sema to-threads)
>> >                        (inc-sema from-threads))))
>> >    (loop repeat thread-count
>> >       do (inc-sema to-threads))
>> >    (loop repeat thread-count
>> >       do (dec-sema from-threads))))
>> >
>> > (defun run ()
>> >  (loop
>> >     (test 16)
>> >     (format t ".")))
>> >
>> > _______________________________________________
>> > Lisp Hug - the mailing list for LispWorks users
>> > lisp-hug@lispworks.com
>> > http://www.lispworks.com/support/lisp-hug.html
>> >
>> >
>> >
>> > ________________________________
>> > Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
>> > ______________________________________________________________________________________
>> >
>> > www.accenture.com
>> >
>> >
>> > _______________________________________________
>> > Lisp Hug - the mailing list for LispWorks users
>> > lisp-hug@lispworks.com
>> > http://www.lispworks.com/support/lisp-hug.html
>> >
>>
>> _______________________________________________
>> Lisp Hug - the mailing list for LispWorks users
>> lisp-hug@lispworks.com
>> http://www.lispworks.com/support/lisp-hug.html
>>
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Stress test failure with threads

I've managed to repeat it now.  The bug that causes condition variables to
hang under stress is fixed in LispWorks 6.1 too.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/


>>>>> On Wed, 13 Jun 2012 21:05:30 -0400, James M Lawrence said:
> 
> Are you writing to confirm that it was fixed in one of the 6.0
> patches, or are you looking to reproduce the hang? If the latter then
> run
> 
> lispworks-personal-6-0-1-x86-linux, md5 0f836edc2f40485ffb07224485bf44e3
> 
> You need to compile the example. I just tried interpreted mode and did
> not see a hang.
> 
> On Wed, Jun 13, 2012 at 10:57 AM, Martin Simmons <martin@lispworks.com> wrote:
> >
> > I can't repeat the hanging with the condition variable implementation in
> > LispWorks 6.0 either.
> >
> > --
> > Martin Simmons
> > LispWorks Ltd
> > http://www.lispworks.com/
> >
> >
> >>>>>> On Wed, 13 Jun 2012 09:57:57 -0400, James M Lawrence said:
> >>
> >> Thanks to all who responded. Unless I hear otherwise I'll assume it's fixed.
> >>
> >> On Thu, Jun 7, 2012 at 9:11 PM,  <ruslan.abdulkhalikov@accenture.com> wrote:
> >> >
> >> > James,
> >> >
> >> > your test seems to work on LW6.1 Linux Ent...
> >> >
> >> > Cheers
> >> > Rus
> >> >
> >> > -----Original Message-----
> >> > From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of James M. Lawrence
> >> > Sent: Friday, 8 June 2012 2:46 AM
> >> > To: lisp-hug@lispworks.com
> >> > Subject: Re: Stress test failure with threads
> >> >
> >> >
> >> > On Thu, Jun 7, 2012 at 10:27 AM, Martin Simmons <martin@lispworks.com> wrote:
> >> >> Yes, this is a bug in the LispWorks 6.0 implementation of semaphores.  It is
> >> >> fixed in LispWorks 6.1.
> >> >
> >> > Thanks for the official word.
> >> >
> >> >>> * Also hangs when semaphores are replaced with blocking queues
> >> >>>   implemented with condition variables.
> >> >>
> >> >> Please post the code for this, because condition variables don't have the same
> >> >> bug AFAIK.
> >> >
> >> > For simplicity I've replaced the queue with a homemade semaphore. The
> >> > following hung between 500 and 17000 iterations in the course of five
> >> > runs.
> >> >
> >> > (defstruct sema
> >> >  (count 0)
> >> >  (lock (mp:make-lock :recursivep nil))
> >> >  (cvar (mp:make-condition-variable)))
> >> >
> >> > (defun inc-sema (sema)
> >> >  (mp:with-lock ((sema-lock sema))
> >> >    (incf (sema-count sema))
> >> >    (mp:condition-variable-signal (sema-cvar sema))))
> >> >
> >> > (defun dec-sema (sema)
> >> >  (mp:with-lock ((sema-lock sema))
> >> >    (loop (cond ((plusp (sema-count sema))
> >> >                 (decf (sema-count sema))
> >> >                 (return))
> >> >                (t
> >> >                 (mp:condition-variable-wait
> >> >                  (sema-cvar sema) (sema-lock sema)))))))
> >> >
> >> > (defun test (thread-count)
> >> >  (let ((from-threads (make-sema))
> >> >        (to-threads   (make-sema)))
> >> >    (loop repeat thread-count
> >> >       do (mp:process-run-function
> >> >           "test" nil (lambda ()
> >> >                        (dec-sema to-threads)
> >> >                        (inc-sema from-threads))))
> >> >    (loop repeat thread-count
> >> >       do (inc-sema to-threads))
> >> >    (loop repeat thread-count
> >> >       do (dec-sema from-threads))))
> >> >
> >> > (defun run ()
> >> >  (loop
> >> >     (test 16)
> >> >     (format t ".")))
> >> >
> >> > _______________________________________________
> >> > Lisp Hug - the mailing list for LispWorks users
> >> > lisp-hug@lispworks.com
> >> > http://www.lispworks.com/support/lisp-hug.html
> >> >
> >> >
> >> >
> >> > ________________________________
> >> > Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
> >> > ______________________________________________________________________________________
> >> >
> >> > www.accenture.com
> >> >
> >> >
> >> > _______________________________________________
> >> > Lisp Hug - the mailing list for LispWorks users
> >> > lisp-hug@lispworks.com
> >> > http://www.lispworks.com/support/lisp-hug.html
> >> >
> >>
> >> _______________________________________________
> >> Lisp Hug - the mailing list for LispWorks users
> >> lisp-hug@lispworks.com
> >> http://www.lispworks.com/support/lisp-hug.html
> >>
> >
> > _______________________________________________
> > Lisp Hug - the mailing list for LispWorks users
> > lisp-hug@lispworks.com
> > http://www.lispworks.com/support/lisp-hug.html
> >
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
> 

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:36 UTC