[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more on light weight mutex



   Date: Tue, 3 Aug 1999 12:41:52 -0500 (CDT)
   From: <joel at oarcorp.com>

   I would propose 3 lightweight wrappers for:

     + obtain, block forever
     + obtain, timeout
     + obtain, poll

On the x86, I would like the code which acquires a mutex to do
something more or less like this (my x86 assembly skills are not
great):

	lock
	addl $1,0(%ebx)
	je	gotit
	call	lock
gotit:	

In other words: use a processor supported interlock instruction to
attempt to acquire the mutex (in this example an unlocked semaphore
holds the value -1).  If that succeeds, fine.  If it fails, call a
subroutine to wait, poll, or whatever.  This sequence is short enough
that it can be done as inline assembler.

   We may still need to put them in an object information table to make
   something work but at first glance I don't see it being necessary.  The
   "id" argument to _CORE_mutex_Seize is for the id of an object you are
   waiting on. I will have to investigate to make sure about the requirement
   for this information.

My personal preference is for mutexes to be very lightweight.  I don't
need them to be listed in a table, and I don't need a name for them
other than a pointer (this is actually generally the case for me--I
never use the RTEMS calls to look up an object by name).

Ian