Read/write locks within and between processes. Can you help?


 
Thread Tools Search this Thread
Top Forums Programming Read/write locks within and between processes. Can you help?
# 1  
Old 02-13-2006
Read/write locks within and between processes. Can you help?

I have an application that is multithreaded and concurrent. Multiple instances of the application must run at the same time.

Each thread in each process accesses shared resources. For this purpose I've employed Butenhof's read-write locks. Inter-process locking is based on fcntl. For example, fcntl is used to prevent a reader from process 1 getting access to a resource that was write locked by a thread from process 2.

I am not sure that this implementation is watertight. Do you know of a "standard" implementation for this kind of mutex? Do you know of another way to implement this kind of locking?

Cheers,
Adam
# 2  
Old 02-13-2006
You want write-execlusive locking, correct?
Otherwise read-shared locking.
# 3  
Old 02-13-2006
Quote:
Originally Posted by jim mcnamara
You want write-execlusive locking, correct?
Otherwise read-shared locking.
I need read-write locks of the kind described by Butenhof in his "Programming with Posix Threads" book. These provide read-shared and write-exclusive access to a resource (not at the same time, naturally) within a process. I need to extend this concept to multiple processes.
# 4  
Old 02-13-2006
An exclusive lock is supposed to stop all other access types, by definition.

You have the right model. It's usually the one implemented for shared memory access across processes - System V semaphores. Normally, there are two semphores (mutexes).

See Section 5.2 Process Semaphores in:

http://www.advancedlinuxprogramming....p-ch05-ipc.pdf
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

FIFO write and read

Can someone help me to write this program in C in QNX? Using the FIFO queues write a simple communication system consisting of programs write and read. The program write the parameters given strings enclosed in single quotes. These strings are written to the FIFO file. Reads the program read... (1 Reply)
Discussion started by: ebasse2
1 Replies

2. Shell Programming and Scripting

File Read and Write

I have got a file in following format: AAAAAAA BBBBBBBB CCCCCCC DDDDDDD I am trying to read this file and out put it in following format: AAAAAAA,BBBBBBB,CCCCCCC,DDDDDD Preferred method is shell or Perl. Any help appreciated. (11 Replies)
Discussion started by: Araoki
11 Replies

3. Programming

Need help about read() and write() on TCP/IP

HI I need to implement a client/server TCP application. the customer is the client and the bartender is the server. When the customer enter the Bar, client connects to the server Server should reply the client immediately. Other wise if the server is busy, it should send an update message... (10 Replies)
Discussion started by: lixiao1212
10 Replies

4. UNIX for Advanced & Expert Users

Multiple processes write to log file at the same time

If we have 3 process to write to same log file at the same time like below. will it cause the data outdated because the multiple process writing same time? It this a safe way to keep the log for multiple process? p1 >> test.log &; p2 >> test.log &; p3 >> test.log & Thanks, (1 Reply)
Discussion started by: casttree
1 Replies

5. Programming

help with write-read locks inter-process

I need help!Many Thanks! Now,I try to manage the shared memory inter-process . Inevitably,I have to deal with the synchronous. I know the pthread_rwlock in posix,and I compile ,then run successfully in Red Hat Enterprise 4. I have a doubt about whether the Posix supports the system such as... (1 Reply)
Discussion started by: weizh
1 Replies

6. IP Networking

write() / read() syntax

hi am newbie to unix and socket programing I am trying to figuring out syntax for read and write to send data from server to client and client can read it I have to send two integers write(newsockfd,buffer,"%d %d",x,y,0) writing from client where x and y are two integers.. ... (7 Replies)
Discussion started by: karthik1238
7 Replies

7. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

8. HP-UX

Read/kill processes

Hi, I read a set of processes with: ps -eaf|grep oracleTRLV The result is: oracle 23253 1 0 15:14:11 ? 0:00 oracleTRLV (LOCAL=NO) oracle 23301 1 0 15:15:07 ? 0:00 oracleTRLV (LOCAL=NO) oracle 22914 1 0 15:11:19 ? 0:00 oracleTRLV (LOCAL=NO) How to I kill the "oracleTRLV" ones? Is there... (17 Replies)
Discussion started by: NicoMan
17 Replies

9. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

10. UNIX for Advanced & Expert Users

how i write script to create 30 processes

helo i make one process for com port . in that i create two thread one for reading data and another for writing data to com port. now i want to write a script which create 30 processes for handling 30 com port. is it good solution for handling 30 com port. Thx & Regards, Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
Login or Register to Ask a Question