Sponsored Content
Full Discussion: Mutex will not work
Top Forums Programming Mutex will not work Post 302288805 by nameless` on Wednesday 18th of February 2009 04:10:58 AM
Old 02-18-2009
I guess you didn't linked the library :

$ gcc -c simple.c
$ gcc -o simple simple.o -lpthread
$ ./simple

the first lock works and the second lock block the program because he is waiting the first lock to be unlocked. (which cannot be done since the program is waiting the lock to be unlocked before continue :])
 

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

How to handle mutex lock?

Hi, I have two tasks 'Read' and 'Write' which reads and writes on a file "abc.txt" respectively. Now I need to restrict the Write operation on the file while Read is going on, But can allow two Reads at a time. ie. two Reads can happen simultaneously, but Write can't happen at Read is going on. ... (3 Replies)
Discussion started by: satheeshalle
3 Replies

5. Programming

difference between Mutex and semaphores

Hi, can someone explain me the difference between mutex and semaphores? Thanks (1 Reply)
Discussion started by: rvan
1 Replies

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

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

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

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

10. 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
tis_write_unlock(3)					     Library Functions Manual					       tis_write_unlock(3)

NAME
tis_write_unlock - Unlocks the specified read-write lock that was acquired for write access. LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <tis.h> int tis_write_unlock( tis_rwlock_t *lock); STANDARDS
None PARAMETERS
Address of the read-write lock to be unlocked. DESCRIPTION
This routine unlocks a read-write lock that was acquired for write access. Upon completion of this routine, any thread waiting to acquire the lock for read access will have those acquisitions granted. If no threads are waiting to acquire the lock for read access, then a thread waiting to acquire it for write access will have that acquisition granted. RETURN VALUES
If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows: Successful completion. The value specified by *lock is invalid. ERRORS
None RELATED INFORMATION
Functions: tis_read_lock(3), tis_read_trylock(3), tis_read_unlock(3), tis_rwlock_init(3), tis_rwlock_destroy(3), tis_write_lock(3), tis_write_trylock(3) Manuals: Guide to DECthreads and Programmer's Guide delim off tis_write_unlock(3)
All times are GMT -4. The time now is 02:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy