comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Subject : locks, semaphores, and such
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Subject : locks, semaphores, and such [message #29070] Sat, 26 January 2002 20:27
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
Hi,

I need to create a unique directory to do some work in. This is a
web-based IDL script (through ION), and multiple people may access the
site at the same second. Each user gets their images generated in a
uniquely named directory, which is then deleted 5 minutes later...

I know a bunch about semaphores and threads and stuff like that, but
here is the problem. The "threads" (users) do not have inter-thread
communication, unless its through files on disk. If they did, this
would be a perfect use for COMMON blocks. Also, the web server has 2
CPUs so much of the traditional semaphore logic is invalid, as both
threads can acquire a lock on the same clock cycle.

---
Here is the code I currently use to lock a file:

uniq = strtrim( long( systime( 1 ) ), 2 )
repeat begin
uniq = uniq + 1L
f = findfile(uniq,count=cnt) ; [1] ; find unclaimed file
endrep until cnt eq 0 ; [2]
spawn, 'touch ' + file ; [3] ; claim file
spawn, 'rm ' + file + ' | at now + 5 minutes' ; free file later

Of course, there are multiple clock cycles and disk accesses between
when [1] loads a "0" into cnt, and when [3] finishes executing the
'touch' part of the command.

The system this runs on is 5 people on 5 computers using 5 different
IDL sessions all sharing 1 cross-mounted disk. So far, the bug has
never evolved into an error :)
---

At worst, can anyone think of a way to detect if multiple users got
assigned the same directory and at least fail gracefully? At best,
does anyone have an algorithm pre-built for just this purpose?

Thanks,
Ken Mankoff

--
Kenneth Mankoff
LASP://303.492.3264
http://lasp.colorado.edu/~mankoff/
http://lasp.colorado.edu/snoedata/
http://lasp.colorado.edu/marsrobot/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: max, mean, min of array
Next Topic: problem after upgrading

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:55:21 PDT 2025

Total time taken to generate the page: 0.00378 seconds