PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

Is implementing a mutex in shared memory the best idea 357


Your Ad Here

Your Ad Here

It sounds to me as if your needs would be well served by a semaphore. semaphores have been around a long time, and should by now be implemented in any operating system that supports shared memory. ipcrm semop semctl semget -- or the posix versions that start with sem* such as seminit semwait

If you are already using POSIX Threads (pthreads), then see pthreadmutexinit pthreadmutexlock and kin.

Perhaps I am reading too much into your words, but it seems to me that you were looking for a way to implement mutexes yourself, based upon some kind of code directly accessing one of the shared locations.

boot from USB drive
I'm trying to make a Thinkpad T40 boot from a 300 GB USB drive. It has booted from other USB things (floppy or HD) without fuss. I can...

Unfortunately, the C programming language does not provide atomic operations -- no "test and set" operation for example. The closest C comes to that is that it does provide sigatomict as a type that can be safely accessed (i.e., read from) even in the presence of interrupts.

If you chase down the various clauses in the C standard, about all you can do is use a volatile sigatomict variable manipulated only within signal handlers that get invoked when you raise() signals... and even then, as C was not designed specifically to be thread-safe, you can't be sure that two different processors cannot enter the same signal handler code at the same time. Trying to implement mutexes via signal handlers is the best you can do in standard C, but it doesn't always work in practice -- and it is almost certain to be slow.

So... you are better off finding a library function (perhaps such as the pthread mutexes) that is implemented by all of the operating systems that are of interest to you. If you are not using pthreads already, you will find semaphores to be lower coding overhead to add in.

Is implementing a mutex in shared memory the best idea 358
There is really only one situation where you should be using a file on a shared drive to transfer data between cluster nodes. That is when you...



Your Ad Here

List | Previous | Next

Is implementing a mutex in shared memory the best idea 358

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

Is implementing a mutex in shared memory the best idea