Mutexes

Discuss Meridian 59 changes.
Post Reply
m59noob
Posts: 1
Joined: Tue May 05, 2020 6:19 am

Mutexes

Post by m59noob » Wed May 06, 2020 5:20 pm

Could someone recommend specific resources and tutorials to read up on mutexes? I have never touched mutexes and am trying to understand the function InitInterfaceLocks() called by MainServer():

Code: Select all

void InitInterfaceLocks()
{
   muxServer = MutexCreate();

   quit = False;
   InitializeCriticalSection(&csQuit);

}

Mutex MutexCreate()
{
    return CreateMutex(NULL, FALSE, NULL);
 }

void InitializeCriticalSection(CRITICAL_SECTION *m)
{
  pthread_mutexattr_t attr;
  pthread_mutexattr_init(&attr);
  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);

  pthread_mutex_init(m, &attr);
}
EvilSibhod
Posts: 35
Joined: Sun Aug 21, 2016 3:47 am
Location: United States

Re: Mutexes

Post by EvilSibhod » Wed May 06, 2020 8:49 pm

A mutex is a flag used to prevent simultaneous access to resources.

While I could make up an analogy, there are plenty of examples here: many of which have good discussions and further reading details.
https://stackoverflow.com/questions/345 ... is-a-mutex
Post Reply