Lisp HUG Maillist Archive

With-timeout

Hello,

Is there a version of with-deadline or with-timeout (as in SBCL,
http://permalink.gmane.org/gmane.lisp.steel-bank.devel/8965) for
Lispworks?  I've looked in the manual for awhile but couldn't find it.

Thank you,
David


Re: With-timeout


Am 13.05.2011 um 15:03 schrieb David L. Rager:

> 
> Hello,
> 
> Is there a version of with-deadline or with-timeout (as in SBCL,
> http://permalink.gmane.org/gmane.lisp.steel-bank.devel/8965) for
> Lispworks?  I've looked in the manual for awhile but couldn't find it.

There are implementations in one or the other portability layer. The more important question is though, why you want to use such a thing? This construct is simply not a good idea**. LispWorks has I/O timeouts with its stream API and it has alot of different tools to control concurrent processes in a sane and coordinated way.

ciao,
Jochen

**) I know it, I implemented one for LispWorks when I ported AllegroServe to it

--
Jochen Schmidt
CRISPYLOGICS
Cross Media Solutions
Uhlandstr. 9, 90408 Nürnberg

Telefon +49 (0)911 517 999 82
Telefax +49 (0)911 517 999 83

mailto:info@crispylogics.com
http://www.crispylogics.com





Re: With-timeout

Jochen Schmidt <jsc@crispylogics.com> writes:

> This construct is simply not a good idea**. 

For instance, you risk aborting cleanup forms in unwind-protect...

> LispWorks has I/O timeouts with its stream API 

To the OP: I highly recommend looking into this. I used to use
with-timeout with Allegro, and IMHO you gain a lot by redesigning your
code to use I/O timeouts if that's what you use with-timeout for.

But I guess there may be cases where with-timout is really useable,
e.g. if you've got some big black box of code that may or may not run
too long and you wish to control it.
-- 
  (espen)


Re: With-timeout

Hi Jochen and Espen,

Thanks for the quick replies.

I need to implement semaphores in user space, because I need a feature
that Gary Byers and I call "semphore notification objects."
Implementing semaphores correctly often brings along with it race
conditions, and the with-deadline construct is useful in implementing
timeouts correctly while avoiding one of these race conditions.

There are probably other ways of doing it -- Martin mentioned one to
me recently, and I'll probably try that if what I'm looking for
doesn't exist.  Issuing an "(apropos 'timeout) yielded many results,
but they all looked specific to a particular function call like
(process-wait/wait-for-stack/etc.-wiith-timeout ...).  I'm wondering
if there's a more general primitive.

Thanks,
David

On Fri, May 13, 2011 at 8:11 AM, Jochen Schmidt <jsc@crispylogics.com> wrote:
>
> Am 13.05.2011 um 15:03 schrieb David L. Rager:
>
>>
>> Hello,
>>
>> Is there a version of with-deadline or with-timeout (as in SBCL,
>> http://permalink.gmane.org/gmane.lisp.steel-bank.devel/8965) for
>> Lispworks?  I've looked in the manual for awhile but couldn't find it.
>
> There are implementations in one or the other portability layer. The more important question is though, why you want to use such a thing? This construct is simply not a good idea**. LispWorks has I/O timeouts with its stream API and it has alot of different tools to control concurrent processes in a sane and coordinated way.
>
> ciao,
> Jochen
>
> **) I know it, I implemented one for LispWorks when I ported AllegroServe to it
>
> --
> Jochen Schmidt
> CRISPYLOGICS
> Cross Media Solutions
> Uhlandstr. 9, 90408 Nürnberg
>
> Telefon +49 (0)911 517 999 82
> Telefax +49 (0)911 517 999 83
>
> mailto:info@crispylogics.com
> http://www.crispylogics.com
>
>
>
>
>


Re: With-timeout

Hi Jochen,

Interesting idea.  You'll be relieved to know that we do everything
with interrupts blocked in the unwind portion of the unwind-protects.

Thanks!
David

On Fri, May 13, 2011 at 9:07 AM, Jochen Schmidt <jsc@crispylogics.com> wrote:
>
>
> Am 13.05.2011 um 15:19 schrieb Espen Vestre:
>
>>
>> Jochen Schmidt <jsc@crispylogics.com> writes:
>>
>>> This construct is simply not a good idea**.
>>
>> For instance, you risk aborting cleanup forms in unwind-protect...
>
> Yes, with this quick hack
>
> (defmacro with-timeout (time &body forms)
>  (with-unique-names (process timer)
>    `(catch 'timeout
>       (let* ((,process mp:*current-process*)
>              (,timer (mp:make-timer (lambda () (mp:process-interrupt
>                                                ,process
>                                                (lambda () (throw 'timeout nil)))))))
>         (mp:schedule-timer-relative ,timer ,time)
>         ,@forms
>         (mp:unschedule-timer ,timer)))))
>
> you could at least use MP:WITH-INTERRUPTS-BLOCKED in unwind-protect.
>
> ciao,
> Jochen
>
> --
> Jochen Schmidt
> CRISPYLOGICS
> Cross Media Solutions
> Uhlandstr. 9, 90408 Nürnberg
>
> Telefon +49 (0)911 517 999 82
> Telefax +49 (0)911 517 999 83
>
> mailto:info@crispylogics.com
> http://www.crispylogics.com
>
>
>
>
>


Re: With-timeout

Sorry for the mostly-needless followup, but I wanted to clarify that
the "everything" refers to "everything related to multi-threading".

On Fri, May 13, 2011 at 9:27 AM, ragerdl <ragerdl@cs.utexas.edu> wrote:
> Hi Jochen,
>
> Interesting idea. You'll be relieved to know that we do everything with interrupts blocked in the unwind portion of the unwind-protects.
>
> Thanks!
> David
>
> On Fri, May 13, 2011 at 9:07 AM, Jochen Schmidt <jsc@crispylogics.com> wrote:
>>
>>
>> Am 13.05.2011 um 15:19 schrieb Espen Vestre:
>>
>>>
>>> Jochen Schmidt <jsc@crispylogics.com> writes:
>>>
>>>> This construct is simply not a good idea**.
>>>
>>> For instance, you risk aborting cleanup forms in unwind-protect...
>>
>> Yes, with this quick hack
>>
>> (defmacro with-timeout (time &body forms)
>>  (with-unique-names (process timer)
>>    `(catch 'timeout
>>       (let* ((,process mp:*current-process*)
>>              (,timer (mp:make-timer (lambda () (mp:process-interrupt
>>                                                ,process
>>                                                (lambda () (throw 'timeout nil)))))))
>>         (mp:schedule-timer-relative ,timer ,time)
>>         ,@forms
>>         (mp:unschedule-timer ,timer)))))
>>
>> you could at least use MP:WITH-INTERRUPTS-BLOCKED in unwind-protect.
>>
>> ciao,
>> Jochen
>>
>> --
>> Jochen Schmidt
>> CRISPYLOGICS
>> Cross Media Solutions
>> Uhlandstr. 9, 90408 Nürnberg
>>
>> Telefon +49 (0)911 517 999 82
>> Telefax +49 (0)911 517 999 83
>>
>> mailto:info@crispylogics.com
>> http://www.crispylogics.com
>>
>>
>>
>>
>>
>
>


Re: With-timeout

One more note, in case anyone looks at this later (I'm assuming these
email lists are searchable).  The call to mp:unschedule-timer should
be part of an unwind-protect with interrupts disabled during the
cleanup form.

Thanks again~

On Fri, May 13, 2011 at 9:07 AM, Jochen Schmidt <jsc@crispylogics.com> wrote:
>
>
> Am 13.05.2011 um 15:19 schrieb Espen Vestre:
>
>>
>> Jochen Schmidt <jsc@crispylogics.com> writes:
>>
>>> This construct is simply not a good idea**.
>>
>> For instance, you risk aborting cleanup forms in unwind-protect...
>
> Yes, with this quick hack
>
> (defmacro with-timeout (time &body forms)
>  (with-unique-names (process timer)
>    `(catch 'timeout
>       (let* ((,process mp:*current-process*)
>              (,timer (mp:make-timer (lambda () (mp:process-interrupt
>                                                ,process
>                                                (lambda () (throw 'timeout nil)))))))
>         (mp:schedule-timer-relative ,timer ,time)
>         ,@forms
>         (mp:unschedule-timer ,timer)))))
>
> you could at least use MP:WITH-INTERRUPTS-BLOCKED in unwind-protect.
>
> ciao,
> Jochen
>
> --
> Jochen Schmidt
> CRISPYLOGICS
> Cross Media Solutions
> Uhlandstr. 9, 90408 Nürnberg
>
> Telefon +49 (0)911 517 999 82
> Telefax +49 (0)911 517 999 83
>
> mailto:info@crispylogics.com
> http://www.crispylogics.com
>
>
>
>
>


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