Lisp HUG Maillist Archive

LWW5 delivered application, multiprocessing, and etc

Hello Lispers

I have been trying to deliver an existing LWW4 application code using
LWW5(with 5.02 patch), without a success.

The application itself is a bit complex, so I made it a simple
example(lww5.lisp, below).

First, I tried save-image(save-lww5.lisp, below). This works exactly I
expected:
* Outputs on the console(the application is console based application)
* The order of the outputs is what I expected: "bar called", then "main
thread called"

Then I tried deliver(deliver-lww5.lisp, below) and had problems:
* It opens new output window for the outputs
* The output order seems wrong - "main thread called" then "bar called"
* When I close the output window, new window with same outputs pops up
several times.
* It never gets quit on time - e.g. >4sec, <5sec.

Does anyone know what's going on and a good solution?

Best regards

Jong-won Choi

;;;***************************** lww5.lisp
(defpackage :foo )

(in-package :foo)

(defun main ()
(hcl:enlarge-static (1- (expt 2 23)))

(in-package "FOO")

(setf mp:*initial-processes*
(nconc mp:*initial-processes*
(list (list "Main Thread" ; This is the function entered
nil ; after delivery.
#'main-thread)
(list "Bar Thread"
nil
#'bar))))
(mp:initialize-multiprocessing))

(defun main-thread ()
(sleep 4)
(print "main-thread called")

(mp:process-wait
"Waiting for something to call stop-app"
#'time-to-stop?)
(user::quit))

(defvar *stop?* nil)

(defun time-to-stop? ()
*stop?*)

(defun bar ()
(sleep 2)
(print "bar called")
(setf *stop?* t))

;;;***************************** lww5.lisp END


;;;***************************** deliver-lww5.lisp
(in-package :cl-user)
(load-all-patches)
(compile-file "lww5.lisp")
(load "lww5")

(hcl:clean-down)
(deliver 'foo::main "c:/Workspace/lww5" 0
:delete-packages
'(capi-library capi-toolkit capi-layout capi
capi-internals
ins hqn-web editor scm
color graphics-ports
)
:keep-complex-numbers nil
:keep-macros t
:keep-pretty-printer t
:keep-clos :full-dynamic-definition
:keep-walker t
:compact t
:editor-commands-to-delete :exclude)
(quit)
;;;***************************** deliver-lww5.lisp END

;;;***************************** save-lww5.lisp
(in-package :cl-user)
(load-all-patches)
(compile-file "lww5.lisp")
(load "lww5")

(hcl:clean-down)
(save-image "c:/Workspace/saved-lww5"
:console t
:environment nil
:clean-down nil
:restart-function 'foo::main)

(quit)
;;;***************************** save-lww5.lisp END


AW: LWW5 delivered application, multiprocessing, and etc



> -----Ursprüngliche Nachricht-----
> Von: owner-lisp-hug@lispworks.com 
> [mailto:owner-lisp-hug@lispworks.com] Im Auftrag von Jong-won Choi
> Gesendet: Mittwoch, 24. Oktober 2007 09:10
> An: lisp-hug@lispworks.com
> Betreff: LWW5 delivered application, multiprocessing, and etc
> 
> 
> 
> Hello Lispers
> 
> I have been trying to deliver an existing LWW4 application 
> code using LWW5(with 5.02 patch), without a success.
> 
> The application itself is a bit complex, so I made it a 
> simple example(lww5.lisp, below).
> 
> First, I tried save-image(save-lww5.lisp, below). This works exactly I
> expected:
> * Outputs on the console(the application is console based application)
> * The order of the outputs is what I expected: "bar called", 
> then "main thread called"
> 
> Then I tried deliver(deliver-lww5.lisp, below) and had problems:
> * It opens new output window for the outputs
> * The output order seems wrong - "main thread called" then 
> "bar called"
> * When I close the output window, new window with same 
> outputs pops up several times.
> * It never gets quit on time - e.g. >4sec, <5sec.
> 
> Does anyone know what's going on and a good solution?
> 
> Best regards
> 
> Jong-won Choi
> 
> ;;;***************************** lww5.lisp
> (defpackage :foo )
> 
> (in-package :foo)
> 
> (defun main ()
> (hcl:enlarge-static (1- (expt 2 23)))
> 
> (in-package "FOO")
> 
> (setf mp:*initial-processes*
> (nconc mp:*initial-processes*
> (list (list "Main Thread" ; This is the function entered
> nil ; after delivery.
> #'main-thread)
> (list "Bar Thread"
> nil
> #'bar))))
> (mp:initialize-multiprocessing))
> 
> (defun main-thread ()
> (sleep 4)
> (print "main-thread called")
> 
> (mp:process-wait
> "Waiting for something to call stop-app"
> #'time-to-stop?)
> (user::quit))
> 
> (defvar *stop?* nil)
> 
> (defun time-to-stop? ()
> *stop?*)
> 
> (defun bar ()
> (sleep 2)
> (print "bar called")
> (setf *stop?* t))
> 
> ;;;***************************** lww5.lisp END
> 
> 
> ;;;***************************** deliver-lww5.lisp
> (in-package :cl-user)
> (load-all-patches)
> (compile-file "lww5.lisp")
> (load "lww5")
> 
> (hcl:clean-down)
> (deliver 'foo::main "c:/Workspace/lww5" 0
> :delete-packages
> '(capi-library capi-toolkit capi-layout capi
> capi-internals
> ins hqn-web editor scm
> color graphics-ports
> )
> :keep-complex-numbers nil
> :keep-macros t
> :keep-pretty-printer t
> :keep-clos :full-dynamic-definition
> :keep-walker t
> :compact t
> :editor-commands-to-delete :exclude)
> (quit)
> ;;;***************************** deliver-lww5.lisp END
> 
> ;;;***************************** save-lww5.lisp
> (in-package :cl-user)
> (load-all-patches)
> (compile-file "lww5.lisp")
> (load "lww5")
> 
> (hcl:clean-down)
> (save-image "c:/Workspace/saved-lww5"
> :console t
> :environment nil
> :clean-down nil
> :restart-function 'foo::main)
> 
> (quit)
> ;;;***************************** save-lww5.lisp END
> 

Jong-won,

just a few quick guesses: When testing I would avoid as many delivery keywords as possible and deliver at level 0 (you already do).
In your case use :multiprocessing t and remove the 'manual' start code of multiprocessing from your program. I experienced
difficulties in doing so. For example sleep did not work correctly when I 'manually' started multiprocessing. I think there is no
need to 'manually' start multiprocessing from code.

Hope this may help a little.

Happy Lisping

Andreas


Re: AW: LWW5 delivered application, multiprocessing, and etc

Hi Andreas

Andreas Thiele 쓴 글:
> In your case use :multiprocessing t and remove the 'manual' start code of multiprocessing from your program. I experienced
> difficulties in doing so. For example sleep did not work correctly when I 'manually' started multiprocessing. I think there is no
> need to 'manually' start multiprocessing from code.
>   

For the simple example, no I don't need to start multiprocessing 
manually, but in the real application(I'm trying to deliver), it has the 
manual multiprocessing start code like one in the simple example.

The application could be delivered correctly with LW4 for Windows and 
Linux, and LW5 for Linux. Only LWW5 has this problem :(

> Hope this may help a little
>   

Thanks for the suggestion. I'm still looking for delivery options to 
build a binary having same behaviour as the saved image, without a 
source code modification, if possible.

> Happy Lisping

Happy Lisping!

- Jong-won


How to access USB port on Mac

Is there a way to access a USB port on a Mac in LW?  

I can do this on a PC using an emulated serial port and the LW serial port
functions, but they are Windows-only.

Mitch


Re: How to access USB port on Mac

There's an amazing Unix tool called netcat (or nc or nc6) that (besides many other things) supports access to a USB port through a TCP/IP stream.

Here's a script that I have used to set it up, in Terminal, but it's been a while since I used it so I'm not sure of all the details.  Diedrich Wolter provided the germ of this idea long ago on the MCL list.  It basically creates a bidirectional pipe between a TCP/IP stream and a Unix device.  I've only used it with MCL, but I don't see any reason it wouldn't work with LispWorks.

#!/bin/sh
tcpipport=$1
usbport=$2
while nc -l -n -p $tcpipport -vv  \
    >$usbport <$usbport | tee serial.out; do echo -----; done

The script takes two args, the TCP/IP port (e.g., 5678) you want to communicate through and the USB port that you're using (e.g., "/dev/cu.usbmodem0B19" has worked for me, but look in "ls /dev/cu.*" for the one that appears on your system).  The "tee" command is for debugging, so you can see what's going on, but is not necessary.

On Oct 24, 2007, at 4:02 AM, Mitch Berkson wrote:


Is there a way to access a USB port on a Mac in LW?  

I can do this on a PC using an emulated serial port and the LW serial port
functions, but they are Windows-only.

Mitch


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