Sponsored Content
Top Forums Programming segmnetation fault by pthread_mutex_unlock on a successfully locked mutex Post 302186845 by jonas.gabriel on Friday 18th of April 2008 08:58:18 AM
Old 04-18-2008
I found my errors...

mutex array size didn't match the initialization loop.
&
inside initialization loop mispelled i with 1.

Excuse me for this useless thread...Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

Threads and Mutex

Hi all, I am working in a UNIX/C environment. I would like to understand more about MUTEX and Threads. Can someone explain me these concepts and how they are related. Vijay (2 Replies)
Discussion started by: vthasan
2 Replies

2. UNIX for Dummies Questions & Answers

mutex

Can anyone explain me what mutexes are in multithreading environment? (2 Replies)
Discussion started by: sagar
2 Replies

3. Shell Programming and Scripting

mutex in shell programing

A shell in crontab per 5 min write a file B shell in crontab per 6 min read a file how to lock the share file a ;avioid confilict in write and read? Thx : -) (1 Reply)
Discussion started by: zz_xm
1 Replies

4. UNIX for Dummies Questions & Answers

what is diff b/w semaphore and mutex

can u tell me what is the exact difference b/w mutex and semaphore and what is the diff b/w counting semaphore and binary semaphore amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

5. Shell Programming and Scripting

Mutex in Perl

Hello Everyone, I just joined this forum and this is my first post. I would like to know how can I impliment basic read/write locks in perl. I have a database (file) which can be accessed simultaneously but has to be locked while writing. If there is no such support in perl, my next... (6 Replies)
Discussion started by: superuser84
6 Replies

6. Programming

Mutex will not work

I am trying to use mutex in my multi-tread project, but they don't seem to work. I have created a simple demonstration of the problem. This is NOT how I would use a mutex, only a demonstration of the problem: #include <stdio.h> #include <pthread.h> int main() { int val; ... (3 Replies)
Discussion started by: ChrisWilliams
3 Replies

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

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

9. Programming

Can Mutex be replaced with anything?

Hi All, To avoid race condition, instead of using mutex, semaphore, spinlock etc.... Is there any other mechanism by which we can avoid race condition in an multi-threading environment. -Thanks (6 Replies)
Discussion started by: rvan
6 Replies

10. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies
pthread_mutex_lock(3T)													    pthread_mutex_lock(3T)

NAME
pthread_mutex_lock(), pthread_mutex_trylock() - lock or attempt to lock a mutex SYNOPSIS
PARAMETERS
mutex Pointer to the mutex to be locked. DESCRIPTION
The mutex object mutex is locked by calling the function. How the calling thread acquires the mutex is dependent upon the type attribute for the mutex. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner. If the mutex type is deadlock detection is not provided. Attempting to relock the mutex causes deadlock. If a thread attempts to unlock a mutex that it has not locked or a mutex which is unlocked, undefined behavior results. If the mutex type is the mutex maintains the concept of an owner. If a thread attempts to relock a mutex that it has already locked, an error shall be returned. If a thread attempts to unlock a mutex that it has not locked or a mutex that is unlocked, an error shall be returned. If the mutex type is then the mutex maintains the concept of an owner and a lock count. When a thread successfully acquires a mutex for the first time, the count field shall be set to one. Every time a thread relocks this mutex, the count field shall be incremented by one. Each time the thread unlocks the mutex, the count field shall be decremented by one. When the count field reaches zero, the mutex shall become available for other threads to acquire. If a thread attempts to unlock a mutex that it has not locked, an error shall be returned. If the mutex type is deadlock detection is not provided. Attempting to relock the mutex causes deadlock. A thread can unlock a mutex that it has not locked. Attempting to unlock an unlocked mutex results in undefined behavior. If the mutex type is attempting to recursively lock the mutex results in undefined behavior. Attempting to unlock the mutex if it was not locked by the calling thread results in undefined behavior. Attempting to unlocked the mutex if it is not locked results in undefined behavior. The function is identical to the function except that if the mutex object referenced by mutex cannot be acquired after one attempt, the call returns immediately with an error. If a signal is delivered to a thread waiting for a mutex, upon return from the signal handler, the thread shall resume waiting for the mutex as if it was not interrupted. RETURN VALUE
Upon successful completion, and return zero. Otherwise, an error number is returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the and functions return the corresponding error number: [EINVAL] mutex is a mutex and the caller's priority is higher than mutex's priority ceiling. If any of the following occur, the function returns the corresponding error number: [EBUSY] mutex is currently locked by another thread. If any of the following occur, the and functions return the corresponding error number: [EAGAIN] mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. This error is not detected on HP-UX. [EINVAL] mutex is not an initialized mutex. [EFAULT] mutex parameter points to an illegal address. If any of the following occur, the function returns the corresponding error number: [EDEADLK] The current thread already owns the mutex. This error will be detected only for mutexes on HP-UX. WARNINGS
A recursive mutex can be locked more than once by the same thread without causing that thread to deadlock. Undefined behavior may result if the owner of a recursive mutex tries to lock the mutex too many times. AUTHOR
and was derived from the IEEE POSIX P1003.1c standard and X/Open SEE ALSO
pthread_mutex_init(3T), pthread_mutex_destroy(3T), pthread_mutex_unlock(3T). STANDARDS CONFORMANCE
Pthread Library pthread_mutex_lock(3T)
All times are GMT -4. The time now is 12:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy