DragonFly BSD
DragonFly commits List (threaded) for 2005-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

cvs commit: src/sys/kern kern_umtx.c init_sysent.c kern_synch.c syscalls.master src/sys/sys param.h syscall-args syscall-hide.h syscall.h syscall.mk sysproto.h systm.h sysunion.h thread.h src/include unistd.h


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Jan 2005 18:20:27 -0800 (PST)

dillon      2005/01/13 18:20:27 PST

DragonFly src repository

  Modified files:
    sys/kern             init_sysent.c kern_synch.c 
                         syscalls.master 
    sys/sys              param.h syscall-args syscall-hide.h 
                         syscall.h syscall.mk sysproto.h systm.h 
                         sysunion.h thread.h 
    include              unistd.h 
  Added files:
    sys/kern             kern_umtx.c 
  Log:
  Add syscall primitives for generic userland accessible sleep/wakeup
  functions.  These functions are capable of sleeping and waking up based on
  a generic user VM address.  Programs capable of sharing memory are also
  capable of interaction through these functions.
  
  Also regenerate our system calls.
  
  umtx_sleep(ptr, matchvalue, timeout)
  
      If *(int *)ptr (userland pointer) does not match the matchvalue,
      sleep for timeout microseconds.  Access to the contents of *ptr plus
      entering the sleep is interlocked against calls to umtx_wakeup().
      Various error codes are turned depending on what causes the function
      to return.  Note that the timeout may not exceed 1 second.
  
  utmx_wakeup(ptr, count)
  
      Wakeup at least count processes waiting on the specified userland
      address.  A count of 0 wakes all waiting processes up.  This function
      interlocks against umtx_sleep().
  
  The typical race case showing resolution between two userland processes is
  shown below.  A process releasing a contested mutex may adjust the contents
  of the pointer after the kernel has tested *ptr in umtx_sleep(), but this does
  not matter because the first process will see that the mutex is set to a
  contested state and will call wakeup after changing the contents of the
  pointer.  Thus, the kernel itself does not have to execute any
  compare-and-exchange operations in order to support userland mutexes.
  
      PROCESS 1			PROCESS 2		******** RACE#1 ******
  
      cmp_exg(ptr, FREE, HELD)
  	.			cmp_exg(ptr, HELD, CONTESTED)
  	.			umtx_sleep(ptr, CONTESTED, 0)
  	.			[kernel tests *ptr]     <<<< COMPARE vs
      cmp_exg(CONTESTED, FREE)		.		<<<< CHANGE
  	.			tsleep(....)
      umtx_wakeup(ptr, 1)			.
  	.				.
  	.				.
  
      PROCESS 1			PROCESS 2		******** RACE#2 ******
  
      cmp_exg(ptr, FREE, HELD)
  				cmp_exg(ptr, HELD, CONTESTED)
  				umtx_sleep(ptr, CONTESTED, 0)
      cmp_exg(CONTESTED, FREE)				<<<< CHANGE vs
      umtx_wakeup(ptr, 1)
  				[kernel tests *ptr]	<<<< COMPARE
  				[MISMATCH, DO NOT TSLEEP]
  
  These functions are very loosely based on Jeff Roberson's umtx work in
  FreeBSD.  These functions are greatly simplified relative to that work in
  order to provide a more generic mechanism.
  
  This is precursor work for a port of David Xu's 1:1 userland threading
  library.
  
  Revision  Changes    Path
  1.21      +3 -1      src/sys/kern/init_sysent.c
  1.41      +17 -4     src/sys/kern/kern_synch.c
  1.16      +2 -0      src/sys/kern/syscalls.master
  1.20      +5 -3      src/sys/sys/param.h
  1.5       +4 -2      src/sys/sys/syscall-args
  1.22      +3 -1      src/sys/sys/syscall-hide.h
  1.22      +4 -2      src/sys/sys/syscall.h
  1.22      +4 -2      src/sys/sys/syscall.mk
  1.22      +21 -2     src/sys/sys/sysproto.h
  1.26      +2 -0      src/sys/sys/systm.h
  1.19      +3 -1      src/sys/sys/sysunion.h
  1.60      +1 -2      src/sys/sys/thread.h
  1.10      +2 -0      src/include/unistd.h


http://www.dragonflybsd.org/cvsweb/src/sys/kern/init_sysent.c.diff?r1=1.20&r2=1.21&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/kern_synch.c.diff?r1=1.40&r2=1.41&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/syscalls.master.diff?r1=1.15&r2=1.16&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/param.h.diff?r1=1.19&r2=1.20&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/syscall-args.diff?r1=1.4&r2=1.5&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/syscall-hide.h.diff?r1=1.21&r2=1.22&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/syscall.h.diff?r1=1.21&r2=1.22&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/syscall.mk.diff?r1=1.21&r2=1.22&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/sysproto.h.diff?r1=1.21&r2=1.22&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/systm.h.diff?r1=1.25&r2=1.26&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/sysunion.h.diff?r1=1.18&r2=1.19&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/thread.h.diff?r1=1.59&r2=1.60&f=u
http://www.dragonflybsd.org/cvsweb/src/include/unistd.h.diff?r1=1.9&r2=1.10&f=u



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