Sponsored Content
Top Forums Programming Question about read writer lock Post 302319504 by fpmurphy on Monday 25th of May 2009 11:07:12 AM
Old 05-25-2009
Robin, it is slightly more complicated ....

From IEEE Std 1003.1-2008. pthread_rwlock_rdlock()

The pthread_rwlock_rdlock() function shall apply a read lock to the read-write lock referenced by rwlock. The calling thread acquires the read lock if a writer does not hold the lock and there are no writers blocked on the lock.

If the Thread Execution Scheduling option is supported, and the threads involved in the lock are executing with the scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not acquire the lock if a writer holds the lock or if writers of higher or equal priority are blocked on the lock; otherwise, the calling thread shall acquire the lock.

If the Thread Execution Scheduling option is supported, and the threads involved in the lock are executing with the SCHED_SPORADIC scheduling policy, the calling thread shall not acquire the lock if a writer holds the lock or if writers of higher or equal priority are blocked on the lock; otherwise, the calling thread shall acquire the lock.

If the Thread Execution Scheduling option is not supported, it is implementation-defined whether the calling thread acquires the lock when a writer does not hold the lock and there are writers blocked on the lock. If a writer holds the lock, the calling thread shall not acquire the read lock. If the read lock is not acquired, the calling thread shall block until it can acquire the lock. The calling thread may deadlock if at the time the call is made it holds a write lock.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to lock keyboard without using lock command

how can I lock my keyboard while I'm away from the computer without using lock command. What other commands gives me the option to lock keyboard device? thanks (7 Replies)
Discussion started by: dianayun
7 Replies

2. AIX

pthread lock question

Is it possible that the function "pthread_cond_broadcast" block itself and the function "pthread_cond_wait" unblock in multi-threads programming ? The operating system is AIX 5.2, its maintenance level is : 5.2.0.4, VisualAge C++ 6.0. Thanks (0 Replies)
Discussion started by: Frank2004
0 Replies

3. UNIX for Dummies Questions & Answers

How to read lock terminal values in solaris

Hi all I am using sun solaris 5.8. I wanna know where the value stored if we lock/unlock the terminal and how i can read and use it to my script. I am helpless . So plzzzzzz... (0 Replies)
Discussion started by: pankajarora_12
0 Replies

4. AIX

Question on CD writer & backup

Hi All, 1. I have many AIX system here but none of them has any CD writer. I want to buy external CD writer so I can move around when needed. Can some one tell me which one they have. Please let me know exact model number so it will be easy for me to order it. I tried going to IBM web site,... (4 Replies)
Discussion started by: samnyc
4 Replies

5. Programming

Will memory leak happen if free reader writer lock without...

Will memory leak happen if free reader writer lock without first calling pthread_rwlock_destroy? (0 Replies)
Discussion started by: robin.zhu
0 Replies

6. Programming

Mutex lock question

Hi all, I have a scenario where I need to use the mutex locks. The mutex locks are working fine, but sometimes I am getting into the dead lock situation. Below is the summary of my code : MUTEX LOCK performTask(); MUTEX UNLOCK. In some cases I get into the situation where... (2 Replies)
Discussion started by: cjjoy
2 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. Red Hat

Security Question: Lock after invalid login, Session Lock and Required Minimum Password Length

Hello all, If anyone has time, I have a few questions: How do I do the following in Linux. We are using Red Hat and Oracle Enterprise Linux, which is based on Red Hat too. 1. How to lock the account after a few (like 3) invalid password attempts? 2. How do you lock a screen after 30... (1 Reply)
Discussion started by: nstarz
1 Replies

9. UNIX for Advanced & Expert Users

Testing privileges -lock lockfile /var/lock/subsys/..- Permission denied

Hi all, I have to test some user priviliges. The goal is to be sure that an unauthorized user can't restart some modules (ssh, mysql etc...). I'm trying to automate it with a shell script but in same cases I got the syslog broadcast message. Is there any way to simply get a return code... (3 Replies)
Discussion started by: Dedalus
3 Replies

10. UNIX for Dummies Questions & Answers

read mail question

how do I save a email I just read to a new file? Thanks. (3 Replies)
Discussion started by: drew211
3 Replies
PTHREAD_RWLOCK_RDLOCK(3)				   BSD Library Functions Manual 				  PTHREAD_RWLOCK_RDLOCK(3)

NAME
pthread_rwlock_rdlock, pthread_rwlock_tryrdlock -- acquire a read/write lock for reading LIBRARY
POSIX Threads Library (libpthread, -lpthread) SYNOPSIS
#include <pthread.h> int pthread_rwlock_rdlock(pthread_rwlock_t *lock); int pthread_rwlock_tryrdlock(pthread_rwlock_t *lock); DESCRIPTION
The pthread_rwlock_rdlock() function acquires a read lock on lock provided that lock is not presently held for writing and no writer threads are presently blocked on the lock. If the read lock cannot be immediately acquired, the calling thread blocks until it can acquire the lock. The pthread_rwlock_tryrdlock() function performs the same action, but does not block if the lock cannot be immediately obtained (i.e., the lock is held for writing or there are waiting writers). A thread may hold multiple concurrent read locks. If so, pthread_rwlock_unlock() must be called once for each lock obtained. The results of acquiring a read lock while the calling thread holds a write lock are undefined. IMPLEMENTATION NOTES
To prevent writer starvation, writers are favored over readers. RETURN VALUES
If successful, the pthread_rwlock_rdlock() and pthread_rwlock_tryrdlock() functions will return zero. Otherwise an error number will be returned to indicate the error. ERRORS
The pthread_rwlock_tryrdlock() function will fail if: [EBUSY] The lock could not be acquired because a writer holds the lock or was blocked on it. The pthread_rwlock_rdlock() and pthread_rwlock_tryrdlock() functions may fail if: [EAGAIN] The lock could not be acquired because the maximum number of read locks against lock has been exceeded. [EDEADLK] The current thread already owns lock for writing. [EINVAL] The value specified by lock is invalid. [ENOMEM] Insufficient memory exists to initialize the lock (applies to statically initialized locks only). SEE ALSO
pthread_rwlock_init(3), pthread_rwlock_trywrlock(3), pthread_rwlock_unlock(3), pthread_rwlock_wrlock(3) STANDARDS
The pthread_rwlock_rdlock() and pthread_rwlock_tryrdlock() functions are expected to conform to Version 2 of the Single UNIX Specification (``SUSv2''). HISTORY
The pthread_rwlock_rdlock() function first appeared in FreeBSD 3.0. BSD
August 4, 1998 BSD
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy