TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: David Noon
from: Murray Lesser
date: 1996-01-26 08:15:00
subject: Pl/i Multithreading

Hi David--

    It seems that learning PL/I is two steps forward and one step back!
It may be almost as bad as C++ .

    I have a little PL/I utility that I use frequently.  It is a local
alarm clock, used to interrupt my session at the console when it is time
to go do something else.  When I invoke it (from a program-object icon)
the window tells me the current system time and asks me to set an alarm
time.  It corrects the time I give it, by 12-hour increments, until that
time is at least 1 minute later than the current system time (up to noon
the following day) and then goes into a coma (DELAY) until the set-time
arrives.  To activate the alarm, it attaches a second thread that beeps
for half of each second while the first thread is blocked until I press
a key (while its window has the focus).  At the keypress, it issues a
DETACH for the second thread and terminates the program with EXIT.  The
beeping stops, the window closes, and all is serene.

    It works as advertised, except for the wrong reasons!  I was doing a
little testing with OS20MEMU to check memory usage in the several phases
of the program, and decided I wanted to see how much of the resources
devoted to the second thread were recovered after that thread was
DETACHed.  So I put in a second "press any key" between the DETACH and
the EXIT.  I discovered that the beeping didn't stop until the second
keypress, which meant that DETACH didn't, EXIT did!  Back to RTFM!  It
appears that I should have used STOP to stop the beeping, not DETACH.
This worked as it should have. 

    Big question:  What does DETACH do, if anything?  I find the manual
very murky on this point.  A small exposition on the subject would be
appreciated.

    Thanks,

          --Murray
 (back to novice class)
___
 * MR/2 2.25 #120 * Which direction is forward?
                                                                                 
---
* Origin: 2" x 4" bbs - a basic board - (914) 271-9407 (1:2625/108)
SEEN-BY: 50/99 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: 2625/108 1 2619/211 3615/50 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™.