mp:process-run-function and a blocking foreign call
"Steven E. Harris" <[email protected]> Mon, 28 Nov 2005 18:29:51 -0800
| Newsgroups | gmane.lisp.allegro |
|---|---|
| Organization | SEH Labs |
| Message-ID | <[email protected]> |
I am running the Allegro CL 7 Trial Edition on Windows XP, and am having trouble using the multiprocessing features (via mp:process-run-function) in conjunction with a blocking foreign function call. Background summary: I have defined foreign function calls out to much of the Windows Smart Card subsystem and can call on these functions from CL with ease. All these calls work as expected. The function I'm working with today is SCardGetStatusChange¹, called on in the manner sketched here.² As discussed in the final paragraph on the second referenced page, SCardGetStatusChange is a blocking function that is designed to be run from a dedicated thread -- one which will presumably then communicate with or start other threads in reaction to certain events. I am able to use my wrapped SCardGetStatusChange function just fine from CL. Running it from the listener, the Allegro CL IDE hangs while SCardGetStatus change is blocked. That's fine for testing this specific function, but of course I'd like to actually run the function in a separate thread. Today I attempted to run my card monitoring function in a separate thread using mp:process-run-function, like so: (mp:process-run-function "monitor" #'monitor-changes 4000) The function gets run, but the IDE still hangs while it's running. I tried starting other threads in parallel as well, doing things like printing random numbers, and while these other threads do get started they obviously hang while the card monitoring function is running. My suspicion is that the foreign function call is to blame for the thread interference, but I don't know what to investigate next. To recap, the blocking card monitoring function works properly, but I can't figure out how to run it in such a way that it doesn't cause other threads (including those running the IDE) to hang. Any advice would be appreciated. Footnotes: ¹ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/scardgetstatuschange.asp ² http://www.softpedal.net/CodeHelp/SCardGetStatusChange.htm -- Steven E. Harris