colin@la.excelan.com (Colin Goldstein) (03/16/91)
The News Manager) Nntp-Posting-Host: la Organization: Novell Inc., Open Systems Div., San Jose CA. Date: Sat, 16 Mar 1991 03:02:54 GMT Hi, I would appreciate some help with the following problem. I have a multi-thread application. There are 4 threads, although only 2 are of interest here. The main thread controls network operations, and thread 2 controls the keyboard. If the user wants to terminate the connection, they hit Esc. When the keyboard thread detects the Esc key stroke, it calls DosFlagProcess and ends. This in turn unblocks the network read (EINTR) and thread 1 cleans up and does some other processing. This all works great. A problem arises however when the server application wants to end the transaction. The network read ends when the connection is closed, but how do I end the keyboard thread??? Here is the code segment I'm using: KbdThread() /* This is thread 2 */ { KBDKEYINFO keyinfo; /* structure for keystroke info. */ USHORT rc; rc = KbdCharIn(&keyinfo, IO_WAIT, 0); if (rc) { // some error; } . . . } I've tried using DosClose(0), which does unblock KbdCharIn() and returns with an error (rc = 3924). This error is undocumented and I'm not sure that the behaviour of STDIN and STDOUT will be after I've done this. I could live with this solution if I knew that this error will be consistant, and if this solution will work in the future. If anyone has any ideas please share them with me. Thanks, Colin -- /-------------------------------------------------------------------\ | The views expressed here are my own. | Norm, what are you | | They do not necessarily represent | up too??? | | the views expressed by my employer. | | | ---------------| My ideal weight if I | | colin@novell.com | Novell Inc., | were 11 feet tall. | | uunet!novell!colin | San Jose | - Cheers | \-------------------------------------------------------------------/
Andreas.Kaiser@p0.f7014.n244.z2.Fidonet.stgt.sub.org (Andreas Kaiser) (03/17/91)
In einer Message an All, vom <16 Mar 142 03:02>, schreibst Du: CG> I have a multi-thread application. There are 4 threads, although CG> only 2 are of interest here. The main thread controls network CG> operations, and thread 2 controls the keyboard. If the user wants CG> to terminate the connection, they hit Esc. When the keyboard thread CG> detects the Esc key stroke, it calls DosFlagProcess and ends. This CG> in turn unblocks the network read (EINTR) and thread 1 cleans up CG> and does some other processing. This all works great. CG> A problem arises however when the server application wants to end CG> the transaction. The network read ends when the connection is closed, CG> but how do I end the keyboard thread??? By DosExit :-). The "famous" multi-threading of OS/2 is seriously incomplete, since the only way to control threads is Suspend. That's it. No signalling, no way to kill a thread. If you need threads which have to communicate by signals or have to kill each other, use parallel processes with shared memory. There is another way: The MSDOS approach ;-). Forget all you learnt about efficient multitasking and do a timer-poll on every resource which does not have a timeout possibility. Not the way OS/2 was built for, but sometimes is the only way to do real-time processing, especially since device monitor calls do not have timeouts. Gruss, Andreas * Origin: kaiser@ananke.stgt.sub.org - Stuttgart (2:244/7014.0)