Skip to content

Commit 73e0a58

Browse files
author
Vladimir Kotal
committed
translate the ftok slide
1 parent 6a1666a commit 73e0a58

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

sys-v-semaphores.tex

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,38 +129,36 @@
129129
\begin{slide}
130130
\sltitle{Creating System V IPC resources}
131131
\begin{itemize}
132-
\item jeden proces prostøedek vytvoøí, ostatní se k nìmu pøipojí.
133-
\item po skonèení pou¾ívání je tøeba prostøedek IPC zru¹it.
134-
\item funkce \texttt{semget()}, \texttt{shmget()} a
135-
\texttt{msgget()} mají jako první parametr klíè identifikující
136-
prostøedek IPC. Skupina procesù, která chce komunikovat, se musí
137-
domluvit na spoleèném klíèi. Rùzné skupiny komunikujících procesù by
138-
mìly mít rùzné klíèe.
132+
\item one process creates the resources, other connect to it.
133+
\item after being done with the resource, it has to be destroyed.
134+
\item \texttt{semget()}, \texttt{shmget()} and
135+
\texttt{msgget()} have the key identifying the resource as a first argument.
136+
Group of processes that want to communicate has to agree on common key.
137+
Different groups of communicating processes should have different keys.
139138
\end{itemize}
140139
\texttt{key\_t \funnm{ftok}(const char *\emph{path}, int \emph{id});}
141140
\begin{itemize}
142-
\item vrátí klíè odvozený ze zadaného jména souboru \texttt{path} a
143-
èísla \texttt{id}. Pro stejné \texttt{id} a libovolnou cestu
144-
odkazující na stejný soubor vrátí stejný klíè. Pro rùzná \texttt{id}
145-
nebo rùzné soubory na stejném svazku vrátí rùzné klíèe.
141+
\item returns key derived from \texttt{path} and \texttt{id} number.
142+
Returns the same key for the same \texttt{id} and arbitrary path referencing the
143+
same file. Returns different keys for different \texttt{id} or different files
144+
on the same volume.
146145
\end{itemize}
147146
\end{slide}
148147

149-
\label{FTOK} poznámky k \texttt{ftok()}:
148+
\label{FTOK} \texttt{ftok()} notes:
150149
\begin{itemize}
151-
\item z \texttt{id} se pou¾ije jen nejni¾¹ích 8 bitù.
152-
\item není specifikováno, zda bude stejný klíè vrácen i po smazání a
153-
znovuvytvoøení souboru. Vìt¹inou ne, proto¾e v klíèi se èasto odrá¾í èíslo
154-
indexového uzlu.
155-
\item rùzné klíèe pro rùzné soubory nejsou v¾dy zaruèené. Napø. na Linuxu se
156-
klíè získá kombinací 16 bitù èísla i-uzlu, 8 bitù \texttt{id} a 8 bitù
157-
vedlej¹ího èísla zaøízení. Stejný klíè pro rùzné soubory je vrácen, pokud se
158-
èísla i-uzlù shodují na spodních 16 bitech.
159-
\item pokud tedy nepøíbuzné procesy chtìjí pou¾ívat stejný semafor, \emsl{musí
160-
být jmého souboru pro klíè domluveno pøedem.}
161-
\item \label{SEM_FIXED_RACE_C} pøíklad na semafory (je to pomocí semaforù
162-
,,opravená'' verze døívej¹ího pøí\-kla\-du \example{race/race.c} ze strany
163-
\pageref{RACE_C}): \example{race/sem-fixed-race.c}.
150+
\item Only the 8 lowest bits are used from the \texttt{id} argument.
151+
\item It is left unspecified whether the same key will be returned across file
152+
deletion. Usually not because the key often reflects inode number.
153+
\item Different keys for different files are not always guaranteed. E.g. on
154+
Linux the key is determined using the combination of 16-bit inode number, 8 bits
155+
of \texttt{id} and 8 bits of minor device number. Same key is returned if the
156+
inode numbers have the same 16 lower bits.
157+
\item If unrelated processes need to use the same semaphore, \emsl{the filename
158+
used for the key needs to be agreed on beforehand.}
159+
\item \label{SEM_FIXED_RACE_C} Example: \example{race/sem-fixed-race.c}
160+
(this is the \example{race/race.c} example from page \pageref{RACE_C} fixed
161+
with semaphores)
164162
\end{itemize}
165163

166164
\endinput

0 commit comments

Comments
 (0)