Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pthread_mutex_lock(3) [freebsd man page]

PTHREAD_MUTEX_LOCK(3)					   BSD Library Functions Manual 				     PTHREAD_MUTEX_LOCK(3)

NAME
pthread_mutex_lock -- lock a mutex LIBRARY
POSIX Threads Library (libpthread, -lpthread) SYNOPSIS
#include <pthread.h> int pthread_mutex_lock(pthread_mutex_t *mutex); DESCRIPTION
The pthread_mutex_lock() function locks mutex. If the mutex is already locked, the calling thread will block until the mutex becomes avail- able. RETURN VALUES
If successful, pthread_mutex_lock() will return zero, otherwise an error number will be returned to indicate the error. ERRORS
The pthread_mutex_lock() function will fail if: [EINVAL] The value specified by mutex is invalid. [EDEADLK] A deadlock would occur if the thread blocked waiting for mutex. SEE ALSO
pthread_mutex_destroy(3), pthread_mutex_init(3), pthread_mutex_trylock(3), pthread_mutex_unlock(3) STANDARDS
The pthread_mutex_lock() function conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). BSD
January 31, 2006 BSD

Check Out this Related Man Page

PTHREAD_MUTEX_TRYLOCK(3)				   BSD Library Functions Manual 				  PTHREAD_MUTEX_TRYLOCK(3)

NAME
pthread_mutex_trylock -- attempt to lock a mutex without blocking LIBRARY
POSIX Threads Library (libpthread, -lpthread) SYNOPSIS
#include <pthread.h> int pthread_mutex_trylock(pthread_mutex_t *mutex); DESCRIPTION
The pthread_mutex_trylock() function locks mutex. If the mutex is already locked, pthread_mutex_trylock() will not block waiting for the mutex, but will return an error condition. RETURN VALUES
If successful, pthread_mutex_trylock() will return zero, otherwise an error number will be returned to indicate the error. ERRORS
The pthread_mutex_trylock() function will fail if: [EINVAL] The value specified by mutex is invalid. [EBUSY] Mutex is already locked. SEE ALSO
pthread_mutex_destroy(3), pthread_mutex_init(3), pthread_mutex_lock(3), pthread_mutex_unlock(3) STANDARDS
The pthread_mutex_trylock() function conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). BSD
July 30, 1998 BSD
Man Page

7 More Discussions You Might Find Interesting

1. Programming

pthread_rwlock_lock vs pthread_mutex_lock

I have been wondering what the difference between pthread_rwlock_lock and pthread_mutex_lock is. Both these routines acquire an exclusive rw lock on an enclosed region. So I performed a simple experiment in which I execute both these routines multiple times in a loop. Here are the results:... (1 Reply)
Discussion started by: kmehta
1 Replies

2. Programming

Interesting issue with pthread_mutex_lock and siglongjmp in AIX 5.3 (and no other OS)

Executive summary: Code (posted below) cores in AIX 5.3, despite being compiled and run successfully on several other operating systems. Code is attempting to verify that pthread_mutex_lock can be successfully aborted by siglongjmp. I do not believe this is an unreasonable requirement. If... (1 Reply)
Discussion started by: DreamWarrior
1 Replies

3. 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

4. Programming

pthread and mutex question

Hello, I have got some issue with the struct variable with passed arguments the variable in the sturct is only recognize the last value their assigned to I'm pretty confused why the mutex didn't work out here is my program: #include<stdio.h> #include<pthread.h> pthread_mutex_t lock... (3 Replies)
Discussion started by: michael23
3 Replies

5. HP-UX

%Internal DCE Threads problem (version CMA BL10+)

Hi, I have a module by the name gateway, and it core dumps and gives a cma_dump.log file which says: %Internal DCE Threads problem (version CMA BL10+), terminating execution. % Reason: dispatch: no available VP (uniprocessor) The current thread is 3 (address 0x40107c40) DECthreads... (0 Replies)
Discussion started by: vanz
0 Replies

6. Programming

Number of threads waiting on a pthread mutex/rwlock

Using pthreads is there a way to determine how many threads are waiting on a locked resource? I mean, once a shared resource is protected using e.g. pthread_rwlock_t or pthread_mutex_t one thread grabs the lock and other threads will go to sleep waiting for the resource to be available again. Is... (0 Replies)
Discussion started by: muggu
0 Replies

7. Programming

design query: where to lock mutex for function accessing global value?

Hi, Suppose I have a function that accesses and increments a global variable . This function is run as part of thread. One locks mutex in the function and unlocks it after the processing is done. Is there any alternative way? Thanks in advance. (1 Reply)
Discussion started by: sanjayc
1 Replies