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 
    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 
  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
  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
  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


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