Re: user-level semaphores!

From: Gavin Nicol <gtn_at_nospam.org>
Date: Mon Nov 28 1994 - 06:20:24 PST

This is what I used for semaphores in user space for MADO so far:

static inline unsigned int
set_semaphore(volatile unsigned int * p, unsigned int newval)
{
        unsigned int semval = newval;
__asm__ __volatile__ ("xchgl %2, %0\n"
                         : /* outputs: semval */ "=r" (semval)
                         : /* inputs: newval, p */ "0" (semval), "m" (*p)
                        ); /* p is a var, containing an address */
        return semval;
}

#define LOCK_SEMAPHORE(x) \
{ \
  while((x)) \
    ; \
  set_semaphore(&(x),1); \
}

#define FREE_SEMAPHORE(x) set_semaphore(&(x),0);
Received on Mon Nov 28 05:55:46 1994

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:10 PDT