Edu-IT Posted January 19, 2010 Posted January 19, 2010 I'm sure this means something to programmers but it had me confused. Am I just thick?
gibbo_ap Posted January 19, 2010 Posted January 19, 2010 (1) Short for mutual exclusion object. In computer programming, a mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. After this stage, any thread that needs the resource must lock the mutex from other threads while it is using the resource. The mutex is set to unlock when the data is no longer needed or the routine is finished. doesnt help at all but it was bugging me as i had heard it before
kmount Posted January 19, 2010 Posted January 19, 2010 [ame=http://en.wikipedia.org/wiki/Mutual_exclusion]Mutual exclusion - Wikipedia, the free encyclopedia[/ame]
powdarrmonkey Posted January 19, 2010 Posted January 19, 2010 A mutex is a lock on a variable, so that you know you can trust it between interrogating it and setting it. Example: I have a variable called var1, which is an ID number for a database row, and two threads - A and B. Thread A checks that var1 equals a sensible row number and then uses it to load the row from the database. However, between checking and using, thread B changes the value to -42, which is rubbish, and thread A gets terminated because it tries to access unallocated memory. A mutex blocks thread B from changing the variable until thread A has finished with it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now