Re: use mutex instead of semaphore in RocketPort driver

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Matthias Kaehlcke
Date: Tuesday, May 22, 2007 - 1:06 pm

El Tue, May 22, 2007 at 09:59:01AM -0700 Arjan van de Ven ha dit:


more buggy than with the use of a semaphore?
 

as far as i understand only the thread that locked the mutex can
unlock it (as opposed to semaphores, which can be released by any
thread/process). obviously this doesn't make the code be more
correct. what i don't know is how the kernel behaves when
trying to unlock a mutex the thread doesn't own. another and possibly
more important problem of the code is that in case of being
interrupted by a signal the data that should be protected by the
mutex/semaphore can be accessed/changed by two threads at the same
time.

would the following resolve the problem?

if(mutex_lock_interruptible(&info->write_mtx)) 
        return -ERESTARTSYS

thanks for your comments

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

            Nothing is more despicable than respect based on fear
                              (Albert Camus)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: use mutex instead of semaphore in RocketPort driver, Arjan van de Ven, (Tue May 22, 9:59 am)
Re: use mutex instead of semaphore in RocketPort driver, Matthias Kaehlcke, (Tue May 22, 1:06 pm)
Re: use mutex instead of semaphore in RocketPort driver, Simon Arlott, (Tue May 22, 2:04 pm)