Home > pthread mutex lock return > pthread_mutex_lock error code 35

Pthread_mutex_lock Error Code 35

Contents

Wiki Search Tutorials/Articles Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming [SOLVED] pthread_mutex_lock returning EDEADLK for a mutex of type PTHREAD_MUTEX_RECURSIVE User pthread_mutex_lock example Name Remember Me? Password Programming This forum is for all programming questions. The pthread_mutex_lock return value question does not have to be directly related to Linux and any language is fair game. Notices Welcome to LinuxQuestions.org, a

Pthread_mutex_lock Return Value 22

friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to

Man Pthread_mutex_lock

threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. pthread_mutex_trylock If you need to reset your password, click here. Having a problem logging in? Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search this Thread 05-28-2010, 04:04 AM #1 nikhil_no_1 LQ Newbie Registered: Sep 2004 Posts: 6 Rep: pthread_mutex_lock returning EDEADLK for a mutex of type PTHREAD_MUTEX_RECURSIVE Hi, I am getting following assertion in my application: pthread_mutex_lock.c:275: __pthread_mutex_lock: Assertion `(e) != 35 || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)' failed. Now, all my mutexes

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company

Pthread_mutex_recursive_np

Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs pthread mutex lock Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just pthread_mutex_initializer like you, helping each other. Join them; it only takes a minute: Sign up pthread_mutex_lock returns invalid argument up vote 4 down vote favorite I am working on some C code and am having a problem with http://www.linuxquestions.org/questions/programming-9/pthread_mutex_lock-returning-edeadlk-for-a-mutex-of-type-pthread_mutex_recursive-810645/ locking a mutex. The code does a call to a function and this function locks a mutex to ensure a file pointer doesn't get overwritten, this works fine for several instances, probably about 10-20 separate calls of the function being called, but on the next call, pthread_mutex_lock will return with a result of 22. I've then put this result into strerror(); and got back invalid argument. What does invalid argument means, thanks for any http://stackoverflow.com/questions/12781944/pthread-mutex-lock-returns-invalid-argument help you can provide. c debugging pthreads mutex share|improve this question edited Oct 8 '12 at 12:43 vy32 9,0311661128 asked Oct 8 '12 at 12:39 Boardy 9,90554168284 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted Sounds like you have a threading problem or a wild point somewhere else in your program. Try printing the value of the mutex pointer. Try having another thread that simply locks the mutex and then prints to a log file the time and that the lock was successful, then unlocks the mutex. I suspect the problem is not where you are looking. Also, as other have said here, your best bet is to create a very small test program that demonstrates the problem and post it here. Chances are you won't be able to get that small program to demonstrate the error. Then slowly add all of your original code into the small program until the error returns. If it returns, you now know what caused the problem. If it doesn't return, you're done. share|improve this answer answered Oct 8 '12 at 12:43 vy32 9,0311661128 add a comment| up vote 7 down vote 22 is ENVAL error code which means invlalid argument. Make sure that you have initilized you mutex, or if at some point you have unitilized it some

to the Single Unix Specification standard consisted to submit an example of use for pthread_sigmask()[1]. Since my proposal was going to be viewed by many Austin Group's contributors (some being http://www.domaigne.com/blog/computing/pthreads-errors-and-errno/ "recognized UNIX authority"), I tried to make my example as perfect as https://forum.juce.com/t/pthread-mutex-lock-full-assertion/7735 possible. In an academic fashion, I checked every function's return code for possible errors. That's where I got it wrong for the Pthreads APIs. Oh well, they do not use errno… The Problem: Before the advent of Pthreads, POSIX functions used to return -1 on error, and set pthread_mutex_lock return the corresponding error code in the global variable errno[2]. This mechanism has a few drawbacks even for single-threaded process: it is not simple to return -1 as valid value. a signal handler may change the errno value between the point a function set errno, and the point where you check the errno variable. Of course, a global errno doesn't work pthread_mutex_lock return value for multi-threaded processes. Indeed, a thread could execute a function that modifies errno just before you check the value in another thread. The (Pthreads) Solution: Since Pthreads, the errno variable is thread-local. That is, every thread has its own "errno copy". If you (or a system function) set the errno variable in one thread, it won't affect the errno value in any other thread. This is shown in the example below. Download errno_01.c1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 /*------------------------------ errno_01.c -------------------------------* compile with: cc -pthread errno_01.c -o errno_01 Copyright Loic Domaigne. Licensed under the Apache License, Version 2.0. *--------------------------------------------------------------------------*/ #include // sleep() #include #include #include #

a _pthreadmutex_lock_full assertion failure in pthread_mutex_lock.c (line 309) - '(-(e)) != 35 || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)'. As I said, this code works fine in Windows. Any ideas why the ScopedLock would act differently in Linux? Thanks! ****Note: Using latest version of Ubuntu.**** Here is the code in Linux where the assertion fails... if (INTERNAL_SYSCALL_ERROR_P (e, __err) && (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH || INTERNAL_SYSCALL_ERRNO (e, __err) == EDEADLK)) { assert (INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)); /* ESRCH can happen only for non-robust PI mutexes where the owner of the lock died. */ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH || !robust); /* Delay the thread indefinitely. */ while (1) pause_not_cancel (); } jules 2011-11-18 18:50:42 UTC #2 Never seen that one before.. Can you give me some code that I could use to reproduce it? jhewell 2011-11-18 19:22:18 UTC #3 I'll see what I can put together. It's part of a very large project with many pieces working together and interacting with hardware over firewire. Let me see if I can reproduce it on a smaller scale example. By the way, do you know what the maximum of locks in a PTHREAD_MUTEX_RECURSIVE lock is - I keep seeing documentation that says there is a maximum but have never seen that value. Thanks. jules 2011-11-18 20:52:21 UTC #4 Is there a maximum? I would have thought it just contained a counter for the recursion depth, rather than having a finite number of slots. jhewell 2011-11-18 21:03:36 UTC #5 That's what I thought, but I found the statement below here - http://pubs.opengroup.org/onlinepubs/007904875/functions/pthread_mutex_lock.html [EAGAIN] [XSI]

 

Related content

No related pages.