TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Peter Schuller
date: 1997-02-02 22:12:10
subject: Multiple threads accessing the same files

Hi!

I'm currently developing a BBS system, and of course - multinode. This means 
that there will be multiple threads or processes (depending on how I'll 
implement it) be accessing the same files! Let's take the message-files 
and file-files for instance. If 4 nodes wishes to read/write to the same 
message/file-base (thus, the same file), how do I coordinate this? Semphores' 
not good, considering there could be 100 nodes running (unlikely, but 50 
maybe). Of course I could make the program try to open the file until it is 
allowed access, but that doesn't seem very effective. Is there any good way to 
"queue" the access? One thing I COULD do (not attractive though)
is to have a 
separeate thread running that receives messages via queues from other threads 
that request the info from data-bases, then extracts the data and writes it to 
a file that only one thread will use. But this is certainly not effective. And 
it could mean trouble if one node adds a file to the list while another node 
read an "off-line" version of it... Oh. I'm rabbeling... Does
anyone have a 
good solution for this? This multithreading-business seem pretty tough, while 
it's very essential.

There is another way I could do it that I find pretty good. But not good 
enough, I'll explain what I mean and maybe you guys have some comments?

Best way I can figure out:

I create a 'access-handleing-thread', that as above receives messages via 
queues or pipes (probably queues, since pipes' point-to-point), and then send 
messages to other threads that requested the access. This thread will then 
have the access until it sends "i'm-finished-let-the-next-thread-get-the-
access" to the access-handleing-thread, that then if there is one, passes the 
access on. But this too can get complicated.

Thanx!

/ Peter Schuller   [TeamOS/2]   petersch{at}kuai.se

--- AdeptXBBS v1.08a26 (VC) (Registered)
* Origin: Gamma Epsilon 24h/day +46-(0)18-367781 (2:206/139)
SEEN-BY: 50/99 54/99 270/101 620/243 625/160 711/401 413 430 934 712/311 407
SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1
@PATH: 206/100 205/625 270/101 712/624 711/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™.