Semaphore vs AbtSemaphore

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Semaphore vs AbtSemaphore

Postby AHodges » Tue Apr 08, 2008 10:47 pm

Hi,
What is the difference between these two classes?
I have a memory from when I was taught that is telling me to always use AbtSemaphore, that there is an issue with using Semaphore. If there is an issue, can someone tell me what it is?

I am trying to debug an intermitent system "hang" and have discovered some uses of the Semaphore class in our legacy code. Just wondering if these hangs are the result of using Semaphore instead of AbtSemaphore.

We are running VA v5.5 on OS/2. Currently porting to VA v7.5 on WinXP and don't know yet whether "hang" can be observed on WInXP.

Thanks,
Andy
AHodges
 
Posts: 10
Joined: Tue Nov 14, 2006 9:46 am
Location: Minneapolis, MN

Re: Semaphore vs AbtSemaphore

Postby John Clapperton » Wed Apr 09, 2008 6:31 am

Hi Andy,

If the active process is the User Interface then waiting at an AbtSemaphore starts a new UI process, and the image stays responsive. But if the code is dinking with process attributes then that may be the wrong thing to do, as the new UI process wouldn't have the same atttributes as the old one. In this case I use a Semaphore, but also an [...] ensure: [sem signal] in the process code which becomes active when the UI process waits, to ensure that the waiting UI process is woken up again, even in the event of early return or unhandled exceptions.

John
http://voss.logicarts.com
John Clapperton
[|]
 
Posts: 18
Joined: Wed Oct 03, 2007 6:21 am

Re: Semaphore vs AbtSemaphore

Postby AHodges » Thu Apr 10, 2008 5:53 am

Thanks for the reply John. Given what you said, I started thinking that our hang was not related to Semaphore/AbtSemaphore. After some more debug, it appears we are hanging on a (Delay forMilliseconds: 1000) wait. I don't yet understand fully how the Delay class is working but it appears to utilize timer interrupts from the Smalltalk VM. Given our hang, and the fact that if we insert a USB card, or PCMCIA card, our app stops hanging and "comes back to life", I am assuming that the Smalltalk VM timer interrupts are temporarily being disabled or suspended.

Remember, this is running VAST v5.5 on OS/2. Has anyone experienced anything similar with using the Delay class?

Replacing the use of the Delay class with OS dosSleep: appears to work without hang.

Thanks,
Andy
AHodges
 
Posts: 10
Joined: Tue Nov 14, 2006 9:46 am
Location: Minneapolis, MN


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest