TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JERRY COFFIN
from: BALOG PAL
date: 1997-08-30 20:24:00
subject: volatile objects?

                              Hi, Jerry Coffin!
On 28 Aug 97  18:09:10 you wrote to Darin Mcbride
 DM> Hmmmm... true.  What do you do to make it "thread-safe"?  Any
 DM> semaphoring, or just the volatile, letting the user do the semaphores?
 JC> Well, I'm actually using critical sections instead of semaphores, but
 JC> the idea's the same, just critical sections are much lower overhead in
 JC> Win32.  In Win32, semapores and mutexes are kernel objects manipulated
 JC> only by kernel code, where critical sections are process-specific and
 JC> are manipulated entirely in user-mode.
I just ran into a problem. Is there something in WIN32 like the ctirical
section in DOS was?   CCriticalSection can be used tiside one proces to keep
threads separate. Global mutexes I can use to sincronice between processes ot
applications, if they are all aware.
But isn't there a simpler method to prevent a task switch for a short section
in the program?  I have a program that is polling directories and moves the
files that apper there to another directories. Another program creates those
files. In several places it simply uses MoveFileEx itself. I found it works
in practice. Bus thinking a bit deeper I consider it's not really safe that
way. What if a task switch occours when the system is in the middle of
MoveFileEx? The poller might start to transfer an incomplete file. (Well,
that probably doesn't happen as I look for file length and it should be >0 to
start a job, and that is probably updated last. But think of the problem in
more general way.)
Well, OTOH if a task could allocate the execution the same way we were back
to old windoze where anyone can lock up the whole system. So probably that
thing really doesn't exist on the user level.
Paul
... Hey!  Your Trakball is upside down!
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)

SOURCE: echomail via exec-pc

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™.