From: Francisco Vides =??B?RmVybsOhbmRleg==?=
Subject: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <ns2dnRsZ79NUGR7U4p2dnAA@giganews.com>
 Dear Lispers

I need to develop a piece of code which will run on Windows machines, doing 
some bidirectional RPC with a central server. I won't need any user 
interface, the software will run as a service. Since I don't have much 
experience developing on such platform, I'm seriously considering to use 
Common Lisp for such task. 

This is my question: can you recommend me any Common Lisp implementation for 
Windows that can assist me in this task. A plus would be a link to some 
documentation. I'd rather use a free implementation, but a commercial one is 
also ok.

After some googling I found that Franz has something about it, I downloaded 
id and will give it a try. Is there some other way to accomplish.

Thanks in advance!

+-----------------
| Francisco Vides Fernández <······@dedaloingenieros.com>
| Director técnico.
| Dédalo Ingenieros http://www.dedaloingenieros.com/
| PGP: http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
+------

From: blandest
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <ae6683b6-58cd-4ce3-abbe-5395c4f1c484@l33g2000pri.googlegroups.com>
On Jan 31, 12:21 am, Francisco Vides =??B?RmVybsOhbmRleg==?=
<······@dedaloingenieros.com> wrote:
>  Dear Lispers
>
> I need to develop a piece of code which will run on Windows machines, doing
> some bidirectional RPC with a central server. I won't need any user
> interface, the software will run as a service. Since I don't have much
> experience developing on such platform, I'm seriously considering to use
> Common Lisp for such task.
>
> This is my question: can you recommend me any Common Lisp implementation for
> Windows that can assist me in this task. A plus would be a link to some
> documentation. I'd rather use a free implementation, but a commercial one is
> also ok.
>
> After some googling I found that Franz has something about it, I downloaded
> id and will give it a try. Is there some other way to accomplish.
>
> Thanks in advance!
>
> +-----------------
> | Francisco Vides Fernández <······@dedaloingenieros.com>
> | Director técnico.
> | Dédalo Ingenieroshttp://www.dedaloingenieros.com/
> | PGP:http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
> +------

It depends on your needs.  A stand alone (command line) application
that will be executed using the Windows Scheduling Tasks service
(under any user that you like) may be enough.

I don't see why people usually choose the more complicated "Windows
Services" way instead of writing a simple program. The only concern is
that this service must run without any users logged on and should stay
"hidden" (no annoying console/gui window). You can accomplish this
using the solution mentioned above.
From: Francisco Vides =??B?RmVybsOhbmRleg==?=
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <J-WdnTVAWdIUER7U4p2dnAA@giganews.com>
blandest wrote:

> On Jan 31, 12:21 am, Francisco Vides =??B?RmVybsOhbmRleg==?=
> <······@dedaloingenieros.com> wrote:
>> Dear Lispers
>>
>> I need to develop a piece of code which will run on Windows machines,
>> doing some bidirectional RPC with a central server. I won't need any user
>> interface, the software will run as a service. Since I don't have much
>> experience developing on such platform, I'm seriously considering to use
>> Common Lisp for such task.

> It depends on your needs.  A stand alone (command line) application
> that will be executed using the Windows Scheduling Tasks service
> (under any user that you like) may be enough.
> 
> I don't see why people usually choose the more complicated "Windows
> Services" way instead of writing a simple program. The only concern is
> that this service must run without any users logged on and should stay
> "hidden" (no annoying console/gui window). You can accomplish this
> using the solution mentioned above.

Excuse my ignorance on windows (I'm a long time Linux user) but Windows 
Scheduling sounds more like cron, it will execute the program at certain 
times. I need a process started when the machine boots (I don't care if 
there's an user logged or not) and keeps executing in background until the 
machine is powered off. So it looks me like a service. Am I wrong?

And, again, can I do it with some Common Lisp implementation (other than 
Allegro, which I've already found)

Thanks

+-----------------
| Francisco Vides Fernández <······@dedaloingenieros.com>
| Director técnico.
| Dédalo Ingenieros http://www.dedaloingenieros.com/
| PGP: http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
+------
From: blandest
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <56e82996-5343-4a02-b55c-35882f6daf61@o40g2000prn.googlegroups.com>
On Jan 31, 1:25 am, Francisco Vides =??B?RmVybsOhbmRleg==?=
<······@dedaloingenieros.com> wrote:
> blandest wrote:
> > On Jan 31, 12:21 am, Francisco Vides =??B?RmVybsOhbmRleg==?=
> > <······@dedaloingenieros.com> wrote:
> >> Dear Lispers
>
> >> I need to develop a piece of code which will run on Windows machines,
> >> doing some bidirectional RPC with a central server. I won't need any user
> >> interface, the software will run as a service. Since I don't have much
> >> experience developing on such platform, I'm seriously considering to use
> >> Common Lisp for such task.
> > It depends on your needs.  A stand alone (command line) application
> > that will be executed using the Windows Scheduling Tasks service
> > (under any user that you like) may be enough.
>
> > I don't see why people usually choose the more complicated "Windows
> > Services" way instead of writing a simple program. The only concern is
> > that this service must run without any users logged on and should stay
> > "hidden" (no annoying console/gui window). You can accomplish this
> > using the solution mentioned above.
>
> Excuse my ignorance on windows (I'm a long time Linux user) but Windows
> Scheduling sounds more like cron, it will execute the program at certain
> times.

Yes, but it will execute on boot too (see schtasks.exe on Windows XP/
2003).

> I need a process started when the machine boots (I don't care if
> there's an user logged or not) and keeps executing in background until the
> machine is powered off. So it looks me like a service. Am I wrong?

The problem with Windows services is that they are harder to maintain
than a simple console application.
I've seen the Allegro API and it looks a little bit too complicated
for what you need (but maybe I've misunderstood your intention ...).
At work, my team is currently maintaining such a service (written in
C# .Net). We don't send custom control commands to this service (only
the standard start/stop). The advantage of simple application is that
you can easily test it using the command line (and your user account).
As far as I know that is impossible with a Windows Service. Also, you
won't depend on some specific implementation that happens to implement
the required API (such as Allegro).

> And, again, can I do it with some Common Lisp implementation (other than
> Allegro, which I've already found)
>
> Thanks
>
> +-----------------
> | Francisco Vides Fernández <······@dedaloingenieros.com>
> | Director técnico.
> | Dédalo Ingenieroshttp://www.dedaloingenieros.com/
> | PGP:http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
> +------
From: Francisco Vides =??B?RmVybsOhbmRleg==?=
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <Ea-dnaI3Sv4eAxnURVn_vwA@giganews.com>
blandest wrote:

>> Excuse my ignorance on windows (I'm a long time Linux user) but Windows
>> Scheduling sounds more like cron, it will execute the program at certain
>> times.
> 
> Yes, but it will execute on boot too (see schtasks.exe on Windows XP/
> 2003).

Then this could be the way to go. Many thanks for your help!

+-----------------
| Francisco Vides Fernández <······@dedaloingenieros.com>
| Director técnico.
| Dédalo Ingenieros http://www.dedaloingenieros.com/
| PGP: http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
+------
From: Pascal J. Bourguignon
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <87fxj0uz8x.fsf@galatea.local>
Francisco Vides =??B?RmVybsOhbmRleg==?= <······@dedaloingenieros.com> writes:

> blandest wrote:
>
>> On Jan 31, 12:21 am, Francisco Vides =??B?RmVybsOhbmRleg==?=
>> <······@dedaloingenieros.com> wrote:
>>> Dear Lispers
>>>
>>> I need to develop a piece of code which will run on Windows machines,
>>> doing some bidirectional RPC with a central server. I won't need any user
>>> interface, the software will run as a service. Since I don't have much
>>> experience developing on such platform, I'm seriously considering to use
>>> Common Lisp for such task.
> [...]
> And, again, can I do it with some Common Lisp implementation (other than 
> Allegro, which I've already found)

clisp works well on MS-Windows.
http://clisp.cons.org/

But if you need to do bidirectional RPC at the same time, you may need
a multi-threaded implementation, which case it's a little too soon for
clisp.  But I'm not sure sbcl can do threads on MS-Windows yet either.

-- 
__Pascal Bourguignon__
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <sqp7o49g5ufhh81mael4j5tdrvqiudvta2@4ax.com>
On Sat, 31 Jan 2009 00:53:50 +0100, ···@informatimago.com (Pascal J.
Bourguignon) wrote:

>Francisco Vides =??B?RmVybsOhbmRleg==?= <······@dedaloingenieros.com> writes:
>
>> blandest wrote:
>>
>>> On Jan 31, 12:21 am, Francisco Vides =??B?RmVybsOhbmRleg==?=
>>> <······@dedaloingenieros.com> wrote:
>>>> Dear Lispers
>>>>
>>>> I need to develop a piece of code which will run on Windows machines,
>>>> doing some bidirectional RPC with a central server. I won't need any user
>>>> interface, the software will run as a service. Since I don't have much
>>>> experience developing on such platform, I'm seriously considering to use
>>>> Common Lisp for such task.
>> [...]
>> And, again, can I do it with some Common Lisp implementation (other than 
>> Allegro, which I've already found)
>
>clisp works well on MS-Windows.
>http://clisp.cons.org/
>
>But if you need to do bidirectional RPC at the same time, you may need
>a multi-threaded implementation, which case it's a little too soon for
>clisp.  But I'm not sure sbcl can do threads on MS-Windows yet either.

It's more than that.  A Windows service that does any significant
processing usually must be multithreaded because there are time limits
for responding to service manager requests - if the program is busy
and doesn't reply, the service manager may kill it.

That said, a lot can be done with a single thread and non-blocking
I/O.  If the problem can be solved by overlapped I/O, a single thread
may be fine.

If the OP has access to Visual Studio, it can generate the framework
of a .NET service in C#.  There are also native service program
frameworks in C and C++ buried in the Windows SDK.  The OP could then
embed ECL or Guile or whatever in the framework.  That would solve the
threading problem if necessary - the thread could be started by the
framework and run the embedded Lisp.

George
From: Francisco Vides =??B?RmVybsOhbmRleg==?=
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <lcedncXNN8n3PhnURVn_vwA@giganews.com>
George Neuner wrote:

>>But if you need to do bidirectional RPC at the same time, you may need
>>a multi-threaded implementation, which case it's a little too soon for
>>clisp.  But I'm not sure sbcl can do threads on MS-Windows yet either.
> 
> It's more than that.  A Windows service that does any significant
> processing usually must be multithreaded because there are time limits
> for responding to service manager requests - if the program is busy
> and doesn't reply, the service manager may kill it.

I will need multithreading since there could me simultaneous incoming 
requests.

> That said, a lot can be done with a single thread and non-blocking
> I/O.  If the problem can be solved by overlapped I/O, a single thread
> may be fine.
> 
> If the OP has access to Visual Studio, it can generate the framework
> of a .NET service in C#.  There are also native service program
> frameworks in C and C++ buried in the Windows SDK.  The OP could then
> embed ECL or Guile or whatever in the framework.  That would solve the
> threading problem if necessary - the thread could be started by the
> framework and run the embedded Lisp.

Many thanks for all your suggestions!

+-----------------
| Francisco Vides Fernández <······@dedaloingenieros.com>
| Director técnico.
| Dédalo Ingenieros http://www.dedaloingenieros.com/
| PGP: http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
+------
From: Jerome Baum
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <uy6wrm4wp.fsf@jeromebaum.com>
Francisco Vides =??B?RmVybsOhbmRleg==?=
<······@dedaloingenieros.com> writes:

> I will need multithreading since there could me simultaneous incoming 
> requests.

Just a FYI, you don't. You can use non-blocking I/O to accept
connections, by using the backlogging features of the sockets
implementation. You should use that anyway.

Of course, more connections than the backlog allows will always
be a problem, even if you multithread.
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <r0gao45ccjh09mlgbv77dfjo0hf3g2jn7p@4ax.com>
On Sat, 31 Jan 2009 20:15:27 +0100, Francisco Vides Fernández
<······@dedaloingenieros.com> wrote:

>George Neuner wrote:
>
>>>But if you need to do bidirectional RPC at the same time, you may need
>>>a multi-threaded implementation, which case it's a little too soon for
>>>clisp.  But I'm not sure sbcl can do threads on MS-Windows yet either.
>> 
>> It's more than that.  A Windows service that does any significant
>> processing usually must be multithreaded because there are time limits
>> for responding to service manager requests - if the program is busy
>> and doesn't reply, the service manager may kill it.
>
>I will need multithreading since there could me simultaneous incoming 
>requests.

Simultaneous I/O requests are not necessarily a reason for
multithreading ... whether you need threads depends more on how many
requests you expect and how much CPU work must be done to service each
one.  With asynchronous I/O, the I/O itself doesn't count as work.

Do you know about the 'select' function in _nix?  Do you know how to
handle multiple sockets (or files) using it?

Windows calls its asynchronous I/O "overlapped" and it works a bit
differently from 'select', but the result is the same ... you start an
I/O operation and go do something else while it happens.  Windows
tells you it's finished by signaling a user provided event (per I/O
call if you like).

You can do quite a lot with asynchronous I/O and a single thread.
It's usually relatively easy to program a state model by breaking up
non-trivial request processing into explicit steps, tracking the
progress of each request, and looping through the active requests
performing the next step when necessary.

You may think "why do that when I have real OS threads"?  Well, OS
threads have not inconsiderable overhead, both in scheduling cycles
and memory.  For high activity server processes, it is frequently more
efficient to handle all the I/O with one thread and use pool threads
if necessary for heavy computing tasks.  You can always add a new I/O
thread if the existing ones are saturated.  
If you go the thread-per-request route, a heavily loaded server runs
the risk of hitting process or system limits, running out of address
space (at least on 32-bit), thrashing, etc.  In general, with a server
process, I think it's preferable to keep the number of OS threads
involved to a minimum.
[I'm sure someone else here will tell you the exact opposite.  Where
people stand on this issue depends on their background ... mine is
operating systems, embedded, real time and high availability (24/7,
uptime in months) applications.  Lots of web programmers see no wrong
in using OS threads.  I say "use them sparingly".  I do support
"green" threading (user space threads) as an alternative to explicit
state models if a decent package is available.  I haven't been very
impressed with green threading in any Lisp I've yet seen.]


Anyway, the normal model of a Windows service is a main thread that
responds to Service Manager requests and one or more worker threads
that do the actual job of the program.  All the threads need to be
coordinated so the Service Manager is aware of the program's status
and can control it.  I haven't seen what Lispworks or Allegro have in
the way of Window service frameworks, but if you embed some Lisp into
a C based service framework I think you'll be better off keeping the
number of threads to a minimum.

George
From: Russell McManus
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <87eiyiz3hw.fsf@thelonious.cl-user.org>
George Neuner <········@comcast.net> writes:

> In general, with a server process, I think it's preferable to keep
> the number of OS threads involved to a minimum.

I think this is generally correct but a useful extension of the idea
is to pick the number of your threads in some ratio to the number of
CPUs on the box.  E.g. if you have an 8 cpu box, then 1 thread is
leaving most of the box idle.  Also >1000 threads is likely not
optimal, due to scheduling overhead.

Probably 8-16 threads is optimal.  Profile, profile, profile, then
choose.

-russ
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <o0deo41498ks5l7ptjgu234smne33e5bh6@4ax.com>
On Sun, 01 Feb 2009 07:32:59 -0600, Russell McManus
<···············@yahoo.com> wrote:

>
>George Neuner <········@comcast.net> writes:
>
>> In general, with a server process, I think it's preferable to keep
>> the number of OS threads involved to a minimum.
>
>I think this is generally correct but a useful extension of the idea
>is to pick the number of your threads in some ratio to the number of
>CPUs on the box.  E.g. if you have an 8 cpu box, then 1 thread is
>leaving most of the box idle.  Also >1000 threads is likely not
>optimal, due to scheduling overhead.
>
>Probably 8-16 threads is optimal.  Profile, profile, profile, then
>choose.
>
>-russ

I agree.  My response to the OP was kind of knee-jerk ... but a lot of
people reach for threads as a first resort rather than analyzing the
problem and deciding whether (and how many) threads are really needed.

George
From: Mark Wooding
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <87bptkof5t.fsf.mdw@metalzone.distorted.org.uk>
Russell McManus <···············@yahoo.com> writes:

> E.g. if you have an 8 cpu box, then 1 thread is leaving most of the
> box idle.

Rather than `idle', I'd say `free for other processes'.  If you're
expecting that your server is the only thing running on the machine, and
you can make use of the extra processors then go for it.

-- [mdw]
From: Alex Mizrahi
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <49858ae4$0$90266$14726298@news.sunsite.dk>
 GN> Do you know about the 'select' function in _nix?  Do you know how to
 GN> handle multiple sockets (or files) using it?

Windows has `select` too 
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <aoceo4536qhrcp3e6rppj042u3uur3fd95@4ax.com>
On Sun, 1 Feb 2009 13:43:30 +0200, "Alex Mizrahi"
<········@users.sourceforge.net> wrote:

> GN> Do you know about the 'select' function in _nix?  Do you know how to
> GN> handle multiple sockets (or files) using it?
>
>Windows has `select` too 
>

Yes, but Windows select() _only_ works with sockets.  _nix select()
also works with files.

You can mix using sockets and files (and pipes and mailboxes) in
Windows but you have to do it with WaitMultipleEvent().

George
From: Florian Weimer
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <8763jrnow0.fsf@mid.deneb.enyo.de>
* George Neuner:

> Yes, but Windows select() _only_ works with sockets.  _nix select()
> also works with files.

On Unix, file I/O does never block (even thought it costs time,
sometimes even more than network I/O).
From: D Herring
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <4988c9fa$0$3338$6e1ede2f@read.cnntp.org>
Florian Weimer wrote:
> * George Neuner:
> 
>> Yes, but Windows select() _only_ works with sockets.  _nix select()
>> also works with files.
> 
> On Unix, file I/O does never block (even thought it costs time,
> sometimes even more than network I/O).

??

Yes it does.  Particularly for NFS, faulty disks, etc.  That "costs 
time" is blocking.
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <drtno45da0p5stvqrgbk5cs1e4th8hdlob@4ax.com>
On Tue, 03 Feb 2009 23:20:47 +0100, Florian Weimer <··@deneb.enyo.de>
wrote:

>* George Neuner:
>
>> Yes, but Windows select() _only_ works with sockets.  _nix select()
>> also works with files.
>
>On Unix, file I/O does never block (even thought it costs time,
>sometimes even more than network I/O).

File I/O can block on local disks due to share locking.  It can block
on network file shares for any number of reasons.

George
From: Kaz Kylheku
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <20090212181040.347@gmail.com>
On 2009-02-06, George Neuner <········@comcast.net> wrote:
> On Tue, 03 Feb 2009 23:20:47 +0100, Florian Weimer <··@deneb.enyo.de>
> wrote:
>
>>* George Neuner:
>>
>>> Yes, but Windows select() _only_ works with sockets.  _nix select()
>>> also works with files.
>>
>>On Unix, file I/O does never block (even thought it costs time,
>>sometimes even more than network I/O).
>
> File I/O can block on local disks due to share locking.  It can block
> on network file shares for any number of reasons.

Your point is correct. However, the kind of blocking that happens in files
cannot be multiplexed with select and poll. Classic Unix has no support for
doing that; in the modern specification, there is <aio.h>.

http://www.opengroup.org/onlinepubs/009695399/basedefs/aio.h.html

If we peek into Linux, for instance, we can see that neither the block file
operations nor the ext2 file operations include a poll virtual function, the
lack of which means that the corresponding objects will unconditionally poll
positive for reading and writing. That is not only not useful, but it
interferes with polling other descriptors by causing poll or select to return
right away.

Polling is really for devices which may cause indefinite suspension that
may occur regardless of the transmission speed or latency.
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <oktpo4hmb5goj3vu2av4dc74icre1dk0v9@4ax.com>
On Fri, 6 Feb 2009 18:53:20 +0000 (UTC), Kaz Kylheku
<········@gmail.com> wrote:

>On 2009-02-06, George Neuner <········@comcast.net> wrote:
>> On Tue, 03 Feb 2009 23:20:47 +0100, Florian Weimer <··@deneb.enyo.de>
>> wrote:
>>
>>>* George Neuner:
>>>
>>>> Yes, but Windows select() _only_ works with sockets.  _nix select()
>>>> also works with files.
>>>
>>>On Unix, file I/O does never block (even thought it costs time,
>>>sometimes even more than network I/O).
>>
>> File I/O can block on local disks due to share locking.  It can block
>> on network file shares for any number of reasons.
>
>Your point is correct. However, the kind of blocking that happens in files
>cannot be multiplexed with select and poll. Classic Unix has no support for
>doing that; in the modern specification, there is <aio.h>.
>http://www.opengroup.org/onlinepubs/009695399/basedefs/aio.h.html
>

Yes.

>If we peek into Linux, for instance, we can see that neither the block file
>operations nor the ext2 file operations include a poll virtual function, the
>lack of which means that the corresponding objects will unconditionally poll
>positive for reading and writing. That is not only not useful, but it
>interferes with polling other descriptors by causing poll or select to return
>right away.
>
>Polling is really for devices which may cause indefinite suspension that
>may occur regardless of the transmission speed or latency.

The point I was trying to make was only that Unix select() and poll()
can detect a signaled file handle while Windows select() cannot.

George
From: Francisco Vides =??B?RmVybsOhbmRleg==?=
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <1fOdnYsja4-xxRrU4p2dnAA@giganews.com>
George Neuner wrote:

> I'm sure someone else here will tell you the exact opposite.  Where
> people stand on this issue depends on their background ... mine is
> operating systems, embedded, real time and high availability (24/7,
> uptime in months) applications.  Lots of web programmers see no wrong
> in using OS threads.

Yeah! Your answer made some os-related-long-unused neural connections blink 
again, and I thank you for that (good food for thought) :)

That said, the problem I'm solving:
 * won't have a high number of requests
 * each request will simply add a new job to a queue to be resolved by an 
human agent, and this will take a long time (hours, maybe days), so high 
response rate is not a problem.

So, to keep things simple, I'll stick to the threads based solution. 

Of course I understand that with other kind of requirements (real time, for 
example) I would be forced to use other kind of solutions.

Many thanks

+-----------------
| Francisco Vides Fernández <······@dedaloingenieros.com>
| Director técnico.
| Dédalo Ingenieros http://www.dedaloingenieros.com/
| PGP: http://pgp.rediris.es:11371/pks/lookup?op=index&search=0xB1299C15
+------
From: MasterZiv
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <941b2fcf-f8dc-4251-881e-b61b12676a94@x6g2000pre.googlegroups.com>
On Jan 31, 10:15 pm, Francisco Vides =??B?RmVybsOhbmRleg==?=
<······@dedaloingenieros.com> wrote:

> I will need multithreading since there could me simultaneous incoming
> requests.

In this case, you have too little to choose from.
Only two CL implementations run multi threading, OpenMCL and SBCL.

Only one is available on Win32, it is SBCL, but SBCL on Win32 still
does NOT
support unix-like SELECT, even then it is supported in Win32 for TCP
sockets.

So I would recommend thinking twice before going this way.
On Unix/linux, LISP is a king, on Win32 things are not that good.
I myself had to switch to linux only to continue development in lisp.
From: Zach Beane
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <m3iqnstk2y.fsf@unnamed.xach.com>
MasterZiv <·········@gmail.com> writes:

> On Jan 31, 10:15 pm, Francisco Vides =??B?RmVybsOhbmRleg==?=
> <······@dedaloingenieros.com> wrote:
>
>> I will need multithreading since there could me simultaneous incoming
>> requests.
>
> In this case, you have too little to choose from.
> Only two CL implementations run multi threading, OpenMCL and SBCL.

Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
all support threads on Windows.

Zach
From: Raffael Cavallaro
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <gm8lst$8b7$1@aioe.org>
On 2009-02-02 19:55:49 -0500, Zach Beane <····@xach.com> said:

> Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
> all support threads on Windows.

Right, but with LispWorks for example only one thread can be running in 
the lisp at a time. Others that are pure foreign calls might run 
concurrently but you can't have two *lisp* threads running concurrently 
on a multi core machine. So even though LispWorks uses native threads, 
those native threads won't use multiple cores if those threads are 
running lisp code.
-- 
Raffael Cavallaro, Ph.D.
From: Marco Antoniotti
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <f2c9198a-3dfc-44e3-92ca-54fda1a2c137@n33g2000pri.googlegroups.com>
On Feb 3, 6:49 am, Raffael Cavallaro
<················@pas.espam.s.il.vous.plait.mac.com> wrote:
> On 2009-02-02 19:55:49 -0500, Zach Beane <····@xach.com> said:
>
> > Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
> > all support threads on Windows.
>
> Right, but with LispWorks for example only one thread can be running in
> the lisp at a time. Others that are pure foreign calls might run
> concurrently but you can't have two *lisp* threads running concurrently
> on a multi core machine. So even though LispWorks uses native threads,
> those native threads won't use multiple cores if those threads are
> running lisp code.

I guess I should just dig in lisp-hug, but isn't this LW limitation
only for MacOS?

Cheers
--
Marco
From: Espen Vestre
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <m1zlh3c2qh.fsf@vestre.net>
Marco Antoniotti <·······@gmail.com> writes:

> I guess I should just dig in lisp-hug, but isn't this LW limitation
> only for MacOS?

No, you're mixing it up with a quite different limitation of the mac
implementation: That all windows run in a common thread.
-- 
  (espen)
From: Raffael Cavallaro
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <gma3bi$ltb$1@aioe.org>
On 2009-02-03 03:58:36 -0500, Marco Antoniotti <·······@gmail.com> said:

> I guess I should just dig in lisp-hug, but isn't this LW limitation
> only for MacOS?

<http://www.lispworks.com/documentation/lw51/LWUG/html/lwuser-238.htm>

"16.5.1 Native threads on Windows, Mac OS X, Linux and FreeBSD
Each Lisp mp:process has a separate native thread. You can have many 
runnable mp:process objects/native threads, but Lisp code can only run 
in one thread at a time and a lock is used to enforce this. This can 
limit performance on multi-CPU machines."


regards,

Ralph

-- 
Raffael Cavallaro, Ph.D.
From: Kaz Kylheku
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <20090209223126.428@gmail.com>
On 2009-02-03, Raffael Cavallaro
<················@pas.espam.s.il.vous.plait.mac.com> wrote:
> On 2009-02-03 03:58:36 -0500, Marco Antoniotti <·······@gmail.com> said:
>
>> I guess I should just dig in lisp-hug, but isn't this LW limitation
>> only for MacOS?
>
><http://www.lispworks.com/documentation/lw51/LWUG/html/lwuser-238.htm>
>
> "16.5.1 Native threads on Windows, Mac OS X, Linux and FreeBSD
> Each Lisp mp:process has a separate native thread. You can have many 
> runnable mp:process objects/native threads, but Lisp code can only run 
> in one thread at a time and a lock is used to enforce this. This can 
> limit performance on multi-CPU machines."

Of course a lock has to be used, for process-wait to be correct!

There is no correct ``condition wait'' without ``monitor enter''.

See for instance:

  _Monitors: an operating system structuring concept_, C. A. R. Hoare, 1974.

Doh! Was this crud by chance implemented before 1974?
From: Pascal Costanza
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <6uqftoFgkmq7U1@mid.individual.net>
Raffael Cavallaro wrote:
> On 2009-02-02 19:55:49 -0500, Zach Beane <····@xach.com> said:
> 
>> Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
>> all support threads on Windows.
> 
> Right, but with LispWorks for example only one thread can be running in 
> the lisp at a time. Others that are pure foreign calls might run 
> concurrently but you can't have two *lisp* threads running concurrently 
> on a multi core machine. So even though LispWorks uses native threads, 
> those native threads won't use multiple cores if those threads are 
> running lisp code.


LispWorks 6.0 will not only have removed that limitation, but will 
actually introduce support for running threads on different cores.


Pascal

-- 
ELS'09: http://www.european-lisp-symposium.org/
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Raffael Cavallaro
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <gma32q$lkc$1@aioe.org>
On 2009-02-03 04:09:14 -0500, Pascal Costanza <··@p-cos.net> said:

> LispWorks 6.0 will not only have removed that limitation, but will 
> actually introduce support for running threads on different cores.

Unfortunately it's not here yet.
-- 
Raffael Cavallaro, Ph.D.
From: Kaz Kylheku
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <20090209222306.829@gmail.com>
On 2009-02-03, Pascal Costanza <··@p-cos.net> wrote:
> Raffael Cavallaro wrote:
>> On 2009-02-02 19:55:49 -0500, Zach Beane <····@xach.com> said:
>> 
>>> Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
>>> all support threads on Windows.
>> 
>> Right, but with LispWorks for example only one thread can be running in 
>> the lisp at a time. Others that are pure foreign calls might run 
>> concurrently but you can't have two *lisp* threads running concurrently 
>> on a multi core machine. So even though LispWorks uses native threads, 
>> those native threads won't use multiple cores if those threads are 
>> running lisp code.
>
>
> LispWorks 6.0 will not only have removed that limitation, but will 
> actually introduce support for running threads on different cores.

To do that they will have to rethink their entire idiotic threading API.

Anyone who thinks that a PROCESS-WAIT function is a good idea, needs to go back
to at least the middle 1970's and read a few papers on concurrency.

How can you safely wait for a condition to become true, and be sure that it's
still true after you are done waiting, if you are not holding a lock, that is
atomically given up when you suspend, and re-acquired, and if you have not
re-tested that the condition is still true?

What they need to do is design a sane new multithreading API, and support the
old API as a backwards-compatibility layer on the new threading.

Threads participating using the old API can be routed to the acquisition of a
global mutex which will serialize them. The process-wait function can work
against that mutex: give up the mutex atomically to go to sleep, then
re-acquire the mutex and re-test the condition, possibly going back to sleep if
it's not true.

New-style thread can explicitly grab the mutex before entering any subsystem
based on the old-style threading. Or use some macro like 

  (mp:with-braindamaged-threading
     (legacy-function))

The macro will acquire and release the necessary lock, with unwind protection.
From: ······@corporate-world.lisp.de
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <c2aa1d68-5ec8-4b31-9af5-b86582200b04@r36g2000prf.googlegroups.com>
On 4 Feb., 00:49, Kaz Kylheku <········@gmail.com> wrote:
> On 2009-02-03, Pascal Costanza <····@p-cos.net> wrote:
>
>
>
> > Raffael Cavallaro wrote:
> >> On 2009-02-02 19:55:49 -0500, Zach Beane <····@xach.com> said:
>
> >>> Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
> >>> all support threads on Windows.
>
> >> Right, but with LispWorks for example only one thread can be running in
> >> the lisp at a time. Others that are pure foreign calls might run
> >> concurrently but you can't have two *lisp* threads running concurrently
> >> on a multi core machine. So even though LispWorks uses native threads,
> >> those native threads won't use multiple cores if those threads are
> >> running lisp code.
>
> > LispWorks 6.0 will not only have removed that limitation, but will
> > actually introduce support for running threads on different cores.
>
> To do that they will have to rethink their entire idiotic threading API.
>
> Anyone who thinks that a PROCESS-WAIT function is a good idea, needs to go back
> to at least the middle 1970's and read a few papers on concurrency.

There are a lot of things that need to be changed. If you have a
specific
application in that area that you want to run on LispWorks
(with concurrent multi-core threading) contact them and let them know
your
requirements.

>
> How can you safely wait for a condition to become true, and be sure that it's
> still true after you are done waiting, if you are not holding a lock, that is
> atomically given up when you suspend, and re-acquired, and if you have not
> re-tested that the condition is still true?
>
> What they need to do is design a sane new multithreading API, and support the
> old API as a backwards-compatibility layer on the new threading.
>
> Threads participating using the old API can be routed to the acquisition of a
> global mutex which will serialize them. The process-wait function can work
> against that mutex: give up the mutex atomically to go to sleep, then
> re-acquire the mutex and re-test the condition, possibly going back to sleep if
> it's not true.
>
> New-style thread can explicitly grab the mutex before entering any subsystem
> based on the old-style threading. Or use some macro like
>
>   (mp:with-braindamaged-threading
>      (legacy-function))
>
> The macro will acquire and release the necessary lock, with unwind protection.
From: Madhu
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <m3bptjdn8d.fsf@moon.robolove.meer.net>
* Kaz Kylheku <··················@gmail.com> :
Wrote on Tue, 3 Feb 2009 23:49:07 +0000 (UTC):
|
| To do that they will have to rethink their entire idiotic threading API.
|
| Anyone who thinks that a PROCESS-WAIT function is a good idea, needs
| to go back to at least the middle 1970's and read a few papers on
| concurrency.

There is nothing wrong with PROCESS-WAIT as an API function in the old
CLIM-SYS multi threading model unless you are trying to use it with the
PTHREADS API which is really a different model with different
characterestics.

| How can you safely wait for a condition to become true, and be sure
| that it's still true after you are done waiting,

Because the other multiprocessing code would conform to your model.

| if you are not holding a lock, that is atomically given up when you
| suspend, and re-acquired, and if you have not re-tested that the
| condition is still true?

This gives away your presumptions on the model. I assume you are using
the PTHREADS API for locks.

| What they need to do is design a sane new multithreading API, and support the
| old API as a backwards-compatibility layer on the new threading.

I believe, but do not know for sure, that SCL, Openmcl all provide this
already, i'm guessing they had this idea before

--
Madhu
From: ······@corporate-world.lisp.de
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <a8d6f655-3982-457b-b803-29c817625be0@z1g2000yqn.googlegroups.com>
On 3 Feb., 06:49, Raffael Cavallaro
<················@pas.espam.s.il.vous.plait.mac.com> wrote:
> On 2009-02-02 19:55:49 -0500, Zach Beane <····@xach.com> said:
>
> > Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
> > all support threads on Windows.
>
> Right, but with LispWorks for example only one thread can be running in
> the lisp at a time. Others that are pure foreign calls might run
> concurrently but you can't have two *lisp* threads running concurrently
> on a multi core machine. So even though LispWorks uses native threads,
> those native threads won't use multiple cores if those threads are
> running lisp code.
> --
> Raffael Cavallaro, Ph.D.

I'm not sure that it does not use multiple cores. The current version
does not run multiple native Lisp threads **concurrently** on multiple
cores. It could still run **non-concurrently** on multiple cores.
From: Raffael Cavallaro
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <gmaeb2$vdv$1@aioe.org>
On 2009-02-03 16:07:31 -0500, ·······@corporate-world.lisp.de" 
<······@corporate-world.lisp.de> said:

> The current version
> does not run multiple native Lisp threads **concurrently** on multiple
> cores. It could still run **non-concurrently** on multiple cores.

This is up to the OS scheduler. However, if the OS scheduler switches 
the lisp between multiple cores the lisp is still limited by only being 
able to use one core at a time.

That said, I have lispworks code that uses multiple cores 
simultaneously - some threads that are pure foreign calls, and some 
threads that are in lisp, so at any given moment, one core runs lisp 
threads, and the other core(s) can (at the OS scheduler's discretion) 
run some of the the foreign code threads simultaneously. For example, 
LWM is now using 175% CPU on my dual core laptop. It would probably 
happily use 200% but there are other processes running ;^)

The more foreign threads you run (in my case, cocoa calls) the less of 
an issue this is.

regards,

Ralph




-- 
Raffael Cavallaro, Ph.D.
From: George Neuner
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <vi0ho4dnb4nherja0top4u1n0rrc4a1jda@4ax.com>
On Mon, 02 Feb 2009 19:55:49 -0500, Zach Beane <····@xach.com> wrote:

>MasterZiv <·········@gmail.com> writes:
>
>> On Jan 31, 10:15�pm, Francisco Vides =??B?RmVybsOhbmRleg==?=
>> <······@dedaloingenieros.com> wrote:
>>
>>> I will need multithreading since there could me simultaneous incoming
>>> requests.
>>
>> In this case, you have too little to choose from.
>> Only two CL implementations run multi threading, OpenMCL and SBCL.
>
>Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
>all support threads on Windows.
>
>Zach

Yes.  The issue, though, is how easy (or hard) any of them make
writing a Windows service application.  

If ACL or LW have a ready framework for writing services then one of
them would obviously be a better choice.  For embedding in a C or C#
framework, Corman is probably the easiest to work with.

George
From: Zach Beane
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <m3ab93tfge.fsf@unnamed.xach.com>
George Neuner <········@comcast.net> writes:

> On Mon, 02 Feb 2009 19:55:49 -0500, Zach Beane <····@xach.com> wrote:
>
>>MasterZiv <·········@gmail.com> writes:
>>
>>> On Jan 31, 10:15 pm, Francisco Vides =??B?RmVybsOhbmRleg==?=
>>> <······@dedaloingenieros.com> wrote:
>>>
>>>> I will need multithreading since there could me simultaneous incoming
>>>> requests.
>>>
>>> In this case, you have too little to choose from.
>>> Only two CL implementations run multi threading, OpenMCL and SBCL.
>>
>>Not true. Corman Lisp, Allegro Common Lisp, and LispWorks Common Lisp
>>all support threads on Windows.
>>
>>Zach
>
> Yes.  The issue, though, is how easy (or hard) any of them make
> writing a Windows service application.  
>
> If ACL or LW have a ready framework for writing services then one of
> them would obviously be a better choice.  For embedding in a C or C#
> framework, Corman is probably the easiest to work with.

The Allegro one I remember from their NFS server for Windows:

  http://opensource.franz.com/ntservice/

I've never tried it myself. Maybe they have something newer now.

Zach
From: David Lichteblau
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <slrngolebm.1kh.usenet-2008@radon.home.lichteblau.com>
On 2009-02-03, George Neuner <········@comcast.net> wrote:
> Yes.  The issue, though, is how easy (or hard) any of them make
> writing a Windows service application.  

It is very easy implement a Windows service in Lisp.

> If ACL or LW have a ready framework for writing services then one of
> them would obviously be a better choice.  For embedding in a C or C#
> framework, Corman is probably the easiest to work with.

ntservice.cl by Franz works well and is unproblematic to use.

Note that it is free software under Lisp-LGPL.  It uses Allegro's FFI,
but should be easy to translate to CFFI, and would also work on other
Lisps then.

(In fact, it would be very easy to rewrite it from scratch based on
Microsoft documentation if you had to, but the existing ntservice.cl
code makes things even easier.)


d.
From: ······@corporate-world.lisp.de
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <9658b017-1f6e-4793-a2fb-22a5e48a1c8a@i18g2000prf.googlegroups.com>
On 2 Feb., 23:21, MasterZiv <·········@gmail.com> wrote:
> On Jan 31, 10:15 pm, Francisco Vides =??B?RmVybsOhbmRleg==?=
>
> <······@dedaloingenieros.com> wrote:
> > I will need multithreading since there could me simultaneous incoming
> > requests.
>
> In this case, you have too little to choose from.
> Only two CL implementations run multi threading, OpenMCL and SBCL.
>
> Only one is available on Win32, it is SBCL, but SBCL on Win32 still
> does NOT
> support unix-like SELECT, even then it is supported in Win32 for TCP
> sockets.
>
> So I would recommend thinking twice before going this way.
> On Unix/linux, LISP is a king, on Win32 things are not that good.
> I myself had to switch to linux only to continue development in lisp.

Corman CL supports full multi-core-threading on Windows. It is not
free, but not very expensive.

A port of Clozure CL to Windows is in the works.
http://trac.clozure.com/openmcl/wiki/WindowsNotes
Clozure CL should also support multi-core-threads.

As already mentioned, LispWorks last year announced
that they are working on a multi-core-threaded
implementation. Currently there is no information
when it will be released.
From: Alex Mizrahi
Subject: Re: Writing a Windows Service in Common Lisp
Date: 
Message-ID: <4984c3ef$0$90274$14726298@news.sunsite.dk>
 FVF> user interface, the software will run as a service.

there is a simple util called srvany -- it installs itself
as a service and then launches your application when service
starts.