![]() |
|
|
#265 | |
|
Nov 2003
22·5·373 Posts |
Quote:
Actually, I have implemented (in the past) a very portable file locking mechanism. When a process wants to read/write (say) file A, it simply checks if A is locked by looking for file 'A.lock'. If A.lock is present, then it sleeps for a few seconds and tries again (length of time determined by how long another process takes to write to and then close file A). If A.lock is NOT present, then the process creates it (preventing other processes from using file A), processes file A, closes file A, then deletes A.lock I used this mechanism to control my NFS code while at RSA. I was running out of a common, shared directory. |
|
|
|
|
|
|
#266 | |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
1075310 Posts |
Quote:
The problem is that more than one process can look for the lock file at the same time, see it is not there, create it and then stomp on the shared file. If the filesystem supports atomic "creation if not present" your mechanism works (though any failure to delete the lock file results in subsequent deadlock of the entire set of clients) but this is special case of mandatory access locking and, unfortunately, is still not portable. It won't necessarily work on some NFS implementations where only advisory locks are possible. Further difficulties can arise from differing interpretations of file system semantics. An obvious one is that some distinguish between alphabetic case and others do not. Some operating systems (thankfully few now) do not allow you to have a zero-length file, so merely creating a file is not enough --- you must write something to it and close it before it becomes visible in the file system to other processes. A good bullet-proof and yet portable file locking system is not easy to write. Even writing one in a pure single-system Unix environment is not trivial. There have been many security vulnerabilities exploited over the years based on race conditions within the filesystem. Paul Last fiddled with by xilman on 2005-11-10 at 16:47 Reason: Fix tag |
|
|
|
|
|
|
#267 | |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
101010000000012 Posts |
Quote:
My experience is that the 2LP/3LP crossover lies at around 100 digits, where NFS is already competitive. Other implementations may put the crossover in other places, of course. If I remember jasonp's earlier investigations with 3LP, he found an even higher crossover point, where NFS will almost certainly be markedly faster than QS. I never use 3LP these days. Paul |
|
|
|
|
|
|
#268 | |
|
Aug 2002
32010 Posts |
Quote:
|
|
|
|
|
|
|
#269 |
|
P90 years forever!
Aug 2002
Yeehaw, FL
2·53·71 Posts |
Another problem is a system or program crash after creating file A.lock. This will block all future accesses to A until someone notices the problem and manually deletes the lock file.
|
|
|
|
|
|
#270 | |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
1075310 Posts |
Quote:
Paul |
|
|
|
|
|
|
#271 | |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
1075310 Posts |
Quote:
Paul |
|
|
|
|
|
|
#272 | |
|
Tribal Bullet
Oct 2004
1101110101012 Posts |
Quote:
jasonp |
|
|
|
|
|
|
#273 | |
|
"Nancy"
Aug 2002
Alexandria
2,467 Posts |
Quote:
POSIX specifies file locking with fcntl(2) which works over NFS. There are two modes: cooperative and mandatory. A file is marked for mandatory locking by setting file mode g-x g+s (pretty ugly!). In this case, the kernel will block accesses. Without the weird file mode, locking is cooperative. I guess that will be the best way for msieve... Alex |
|
|
|
|
|
|
#274 | |
|
Tribal Bullet
Oct 2004
3,541 Posts |
Quote:
I've been working with someone else who is well on the way to making the msieve demo a client-server application that communicates via sockets, although I don't know when / if such a beast will be ready. In other news, a few more parameter tweaks have made smaller factorizations noticeably faster too. I think I'll spend a little more time tuning things at the 95-110 digit level. jasonp |
|
|
|
|
|
|
#275 |
|
"Nancy"
Aug 2002
Alexandria
9A316 Posts |
For larger factorisations, I'll definitely keep using S/GNFS. But Paul Zimmermann and I frequently encounter composites around 100 digits in factoring Aliquot sequences and it would be really convenient to just fire up a few msieve processes on whatever cpus are free at the moment and pick up the factors 30 minutes later...
One thing the file locking idea has going for it is that processes can be added/removed dynamically without specifying a master process or anything. It's simple and convenient for the user if nothing else. Problems I can see: when starting factorisations on different numbers in the same directory. How would processes know that the msieve.dat file is currently in use and not a leftover from an old factorisation? Also, if processes are designated to only sieving (i.e. post-processing inhibited) it should be more efficient to not let them count cycles, but only dump relations into the msieve.dat file. However, if all processes that can post-process die, the only-sievers will keep sieving until the end of time (or the hard disk fills up, whichever comes first). Alex |
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Utility of integer factorization. | jwaltos | Other Mathematical Topics | 8 | 2015-05-22 12:20 |
| File Splitting Utility | Antonio | Software | 5 | 2013-04-18 14:22 |
| Low-powered motherboard of adequate capability sought | fivemack | Hardware | 1 | 2011-12-21 19:26 |
| Implementing MPQS: SOS! | smoking81 | Factoring | 10 | 2007-10-02 12:30 |
| Prime Shuffle Utility | HiddenWarrior | Programming | 6 | 2004-11-04 05:21 |