TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Alan Clifford
from: Mike Bilow
date: 1996-03-29 22:46:26
subject: Threads

Alan Clifford wrote in a message to Mike Bilow:

 MB> As I read my own words again, I realize that I forgot to mention an
 MB> additional concern.  If you do not post the event semaphore after
 MB> every byte, you must set up a handler for the special case where you
 MB> get an otherwise unhandled residue in the buffer.  For example, if
 MB> you trigger the event semaphore every 10 bytes, and you physically
 MB> receive 5 bytes, then those 5 bytes will sit in the buffer forever
 MB> unless you either receive 5 more bytes or do something special to get
 MB> them out of there.

 AC> I thought about putting a "timerout" on the event semaphore
 AC> to cover this but that would mean the thread would run even
 AC> if there were no characters waiting.  Rather defeats the
 AC> object of using an event semaphore.

No, no... don't do that.

 MB> This may sound like a really obvious observation, but it is a common

 AC> Nothing is obvious at the moment.  All help gratefully 
 AC> received. 

I know where you're coming from...

 MB> One common approach is to use a timer to post the event semaphore. 
 MB> Then, when a byte is inserted into the buffer and the timer is not

 AC> Aha, I'd better read the chapter on timers.

Well, I did mention programming complexity for a reason.  You end up having
to create another mutex semaphore to protect the timer from being reset
once it is started, so then you end up with: (1) a mutex semaphore to
serialize data insertion into and extraction from the buffer, (2) an event
semaphore to signal that data must be extracted from the buffer, (3) a
timer started when data is inserted that expires in order to post the event
semaphore which signals the need for extraction, and (4) a mutex semaphore
to serialize setting and resetting the timer.

 AC> I've got "OS/2 Warp Control Program API" by Marc Stock
 AC> (well, the local library bought it for me).  It doesn't
 AC> cover IOCTLs.  Here I am with the money in my hot little
 AC> hands but the local bookshops don't carry more than "The
 AC> idiot child's guide to OS/2 programming - vital bits missed
 AC> out edition" for me to look at before I buy.  A trip to the
 AC> London bookshops is required I think.  Is any of this stuff
 AC> is available online?

There is always Computer Literacy Bookshops, http://www.clbooks.com, which
will gladly ship overseas orders.  Some of your countrymen may be better
able to help you on this, however.  I assume that there must be somewhere
in the UK where OS/2 programming books are available, even if it is
Hursley.

You can also order the Developer Connection CD-ROM, which is sold by annual
subscription and issued quarterly.  Each issue is about six disks, and
these contain copious amounts of documentation on nearly everything in
OS/2.  I don't know how you go about obtaining it in the UK, but there is
information on-line at http://www.developer.ibm.com or by e-mail to
devcon{at}vnet.ibm.com.
 
-- Mike


---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 323/107 170/400 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.