Skip to content

Commit 3c3cb5b

Browse files
author
Vladimir Kotal
committed
more on unnamed semaphores
1 parent 6c817bb commit 3c3cb5b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

synchro.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@
562562

563563
\pdfbookmark[1]{sem\_open, sem\_wait, sam\_post, sem\_close}{posix-semaphores}
564564

565+
\label{NAMED_SEMAPHORES}
565566
\begin{slide}
566567
\sltitle{POSIX API for semaphores}
567568

threads.tex

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,19 +1235,32 @@
12351235
12361236
%%%%%
12371237
1238-
\pdfbookmark[1]{sem\_init, sem\_post, sem\_wait}{semafory}
1238+
\pdfbookmark[1]{sem\_init, sem\_post, sem\_wait}{semaphores}
12391239
12401240
\begin{slide}
1241-
\sltitle{POSIX Semaphores}
1241+
\sltitle{POSIX Semaphores -- unnamed}
12421242
\begin{itemize}
12431243
\item semaphores come from POSIX-1003.1b (real-time extensions)
12441244
\item the function names do not begin with \emsl{pthread\_}, but \emsl{sem\_}
1245-
(\texttt{sem\_init}, \texttt{sem\_post}, \texttt{sem\_wait}, \dots)
12461245
\item possible to use them with threads
12471246
\end{itemize}
1247+
\texttt{int \funnm{sem\_init}(sem\_t *\emph{s},
1248+
int \emph{pshared}, unsigned int \emph{value});}
1249+
\begin{itemize}
1250+
\item initialize semaphore
1251+
\item The \funnm{sem\_post} and \funnm{sem\_wait} are the same as for named
1252+
semaphores (see page \pageref{NAMED_SEMAPHORES})
1253+
\end{itemize}
1254+
\texttt{int \funnm{sem\_destroy}(sem\_t *\emph{s});}
1255+
\begin{itemize}
1256+
\item destroys the unnamed semaphore
1257+
\end{itemize}
12481258
\end{slide}
12491259
12501260
\begin{itemize}
1261+
\item Sempahores created using this API do not have a name (as opposed to
1262+
those created via the \texttt{sem\_open} function), hence they are called
1263+
unnamed.
12511264
\item The semaphore functions adhere to the classical UNIX semantics --
12521265
they return -1 on error and set \texttt{errno}.
12531266
\end{itemize}

0 commit comments

Comments
 (0)