nanogui: Thread-safety, wrapping globals in structs, RTEMS


Previous by date: 20 Dec 2000 22:13:19 -0000 vt52 textpanel object, Kaben Nanlohy
Next by date: 20 Dec 2000 22:13:19 -0000 Re: Thread-safety, wrapping globals in structs, RTEMS, Jason C. Garcowski
Previous in thread: 20 Dec 2000 22:13:19 -0000 Re: Thread-safety, wrapping globals in structs, RTEMS, Kaben Nanlohy
Next in thread: 20 Dec 2000 22:13:19 -0000 Re: Thread-safety, wrapping globals in structs, RTEMS, Jason C. Garcowski

Subject: Re: Thread-safety, wrapping globals in structs, RTEMS
From: "Greg Haerr" ####@####.####
Date: 20 Dec 2000 22:13:19 -0000
Message-Id: <015101c06ad3$41566a80$6817dbd0@censoft.com>

: Call these hooks "Gr(Un)LockSomethingOrOther()" or
: "GrObtainSomeSemaphore()"...  Does anyone want to name these functions
: after their favorite pet or anything like that?

Use
    LOCK(mutex)
and
    UNLOCK(mutex)

where LOCK and UNLOCK are #define's.  In addition,
the mutex itself can be declared as a MUTEX, allowing
any different means of critical section handling routines
to be used without having to re-hack Nano-X all the time.

Since we're talking about code that's internal to Nano-X,
we won't use the GrXXX functions, since they're not allowed
to be called by users.

At this point, I'd recommend a #include "mutex.h" in serv.h,
with the 

#if RTEMS_MUTEX
#include <pthread.h>
#define MUTEX            pthread_mutex
#define LOCK(mutex)   pthread_lock(&mutex)
#endif
etc 

or whatever in mutex.h.

Then, a single global mutex can be used in each GrXXX routine
to guarantee thread safety.

Regards,

Greg


Previous by date: 20 Dec 2000 22:13:19 -0000 vt52 textpanel object, Kaben Nanlohy
Next by date: 20 Dec 2000 22:13:19 -0000 Re: Thread-safety, wrapping globals in structs, RTEMS, Jason C. Garcowski
Previous in thread: 20 Dec 2000 22:13:19 -0000 Re: Thread-safety, wrapping globals in structs, RTEMS, Kaben Nanlohy
Next in thread: 20 Dec 2000 22:13:19 -0000 Re: Thread-safety, wrapping globals in structs, RTEMS, Jason C. Garcowski


Powered by ezmlm-browse 0.20.