From owner-svn-src-user@FreeBSD.ORG Tue Oct 15 15:43:29 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8FF06D0A; Tue, 15 Oct 2013 15:43:29 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7E55420AA; Tue, 15 Oct 2013 15:43:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9FFhTAM009871; Tue, 15 Oct 2013 15:43:29 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9FFhTeW009869; Tue, 15 Oct 2013 15:43:29 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201310151543.r9FFhTeW009869@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 15 Oct 2013 15:43:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256545 - user/glebius/course/04.synchronisation X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2013 15:43:29 -0000 Author: glebius Date: Tue Oct 15 15:43:29 2013 New Revision: 256545 URL: http://svnweb.freebsd.org/changeset/base/256545 Log: More unfinished stuff on synchronisation. Modified: user/glebius/course/04.synchronisation/lection.tex Modified: user/glebius/course/04.synchronisation/lection.tex ============================================================================== --- user/glebius/course/04.synchronisation/lection.tex Tue Oct 15 15:00:53 2013 (r256544) +++ user/glebius/course/04.synchronisation/lection.tex Tue Oct 15 15:43:29 2013 (r256545) @@ -12,6 +12,8 @@ \usetikzlibrary{positioning} \usetikzlibrary{shapes} +\usetikzlibrary{arrows} +\usetikzlibrary{chains} \usetikzlibrary{calc} \input{../course.tex} @@ -207,16 +209,63 @@ mtx\_lock:\\ #define MTX_CONTESTED 0x00000002 /* lock contested */ #define MTX_UNOWNED 0x00000004 /* free mutex */ -atomic_cmpset_acq_ptr(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) +atomic_cmpset_acq_ptr(&(mp)->mtx_lock, MTX_UNOWNED, (td)) \end{verbatim} \end{frame} -\FootReferences{mutex(9)}{sys/kern/mutex.h, sys/kern/kern_mutex.c} +\FootReferences{mutex(9)}{sys/kern/mutex.h, sys/kern/kern\_mutex.c} \begin{frame} \frametitle{mutex(9) implementation} - +\begin{figure} +\begin{tikzpicture}[>=triangle 60, start chain=going below, + node distance=5mm, + every join/.style={->, draw}, + font=\scriptsize] +\tikzset { + base/.style={draw, thick, on chain, align=center, minimum height=4ex}, + proc/.style={base, rectangle}, + test/.style={base, diamond, aspect=3}, + term/.style={proc, rounded corners}, +} +\node [name=entry, proc] {mtx\_lock()}; +\node [name=atomic, test] {atomic\_cmpset(td)}; +\node [name=exit, term] {return}; +\node [name=ownerruns, test, right=of atomic] {owner running?}; +\node [name=trywait, proc] {turnstile\_trywait}; +\node [name=ownerruns2, test, join] {owner running?}; +\node [name=contested, test] {atomic\_cmpset(C)}; +\node [name=wait, proc, left=of contested] {turnstile\_wait}; +\node [name=cancel, proc, right=of ownerruns2] {turnstile\_cancel}; + +\draw [->] (entry.south) to node [name=entry2,midway] {} (atomic); +\draw [->] (atomic.south) to node [xshift=1em, green] {$yes$} (exit); +\draw [->] (atomic.east) to node [yshift=1em, red] {$no$} (ownerruns); +\draw [->] (ownerruns.south) to node [xshift=1em, green] {$yes$} (trywait); +\draw [->] (ownerruns.north) |- node [xshift=1ex, yshift=-1ex, red] {$no$} + (entry2.center); +\draw [->] (ownerruns2.south) to node [xshift=1em, green] {$yes$} (contested); +\draw [->] (ownerruns2.east) to node [yshift=1em, red] {$no$} (cancel); +\draw [->] (cancel.north) |- (entry2.center); +\draw [->] (contested.east) -| node [pos=0, yshift=1em, red] {$no$} + (cancel.south); +\draw [->] (contested.west) to node [yshift=1em, green] {$yes$} (wait); +\draw [->] (wait) -- (atomic.west |- wait) -- +(-2mm, 0) |- (entry2.center); +\end{tikzpicture} +\end{figure} \end{frame} +\FootReferences{mutex(9)}{sys/kern/subr\_turnstile.c, sys/kern/kern\_mutex.c} +\begin{frame} +\frametitle{mutex(9) implementation: turnstile} +\begin{figure} +\begin{tikzpicture}[every node/.style={draw, node distance=10mm}] + \node [name=turnstile, struct, rectangle split parts = ] + \textbf{struct turnstile} + \nodepart{two} LIST\_HEAD ts\_blocked + \nodepart{two} LIST\_HEAD ts\_pending +\end{tikzpicture} +\end{figure} +\end{frame} \end{document}