File: proto.tex

package info (click to toggle)
spooles 2.2-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,760 kB
  • sloc: ansic: 146,836; sh: 7,571; csh: 3,615; makefile: 1,970; perl: 74
file content (117 lines) | stat: -rw-r--r-- 4,369 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
\par
\section{Prototypes and descriptions of {\tt Lock} methods}
\label{section:Lock:proto}
\par
\subsection{Basic methods}
\label{subsection:Lock:proto:basics}
\par
As usual, there are four basic methods to support object creation,
setting default fields, clearing any allocated data, and free'ing
the object.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
Lock * Lock_new ( void ) ;
\end{verbatim}
\index{Lock_new@{\tt Lock\_new()}}
This method simply allocates storage for the {\tt Lock} structure 
and then sets the default fields by a call to 
{\tt Lock\_setDefaultFields()}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Lock_setDefaultFields ( Lock *lock ) ;
\end{verbatim}
\index{Lock_setDefaultFields@{\tt Lock\_setDefaultFields()}}
This method sets the structure's fields to default values:
{\tt nlocks} and {\tt nunlocks} are zero, and {\tt mutex} is {\tt NULL}.
\par \noindent {\it Error checking:}
If {\tt lock} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Lock_clearData ( Lock *lock ) ;
\end{verbatim}
\index{Lock_clearData@{\tt Lock\_clearData()}}
This method clears the data for the object.
If {\tt lock->mutex} is not {\tt NULL}, 
then {\tt mutex\_destroy(lock->mutex)} is called 
(for the Solaris thread package)
or {\tt pthread\_mutex\_destroy(lock->mutex)} is called 
(for the POSIX thread package),
The method concludes with a call to {\tt Lock\_setDefaultFields()}.
\par \noindent {\it Error checking:}
If {\tt lock} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Lock_free ( Lock *lock ) ;
\end{verbatim}
\index{Lock_free@{\tt Lock\_free()}}
This method releases any storage by a call to 
{\tt Lock\_clearData()} then free's the storage for the 
structure with a call to {\tt free()}.
\par \noindent {\it Error checking:}
If {\tt lock} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsection{Initializer method}
\label{subsection:Lock:proto:initializers}
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Lock_init ( Lock *lock, int lockflag ) ;
\end{verbatim}
\index{Lock_init@{\tt Lock\_init()}}
This is the basic initializer method.
Any previous data is cleared with a call to {\tt Lock\_clearData()}.
If {\tt lockflag = 0}, then no lock is initialized.
For the Solaris thread package, {\tt lockflag = 1} means the lock
will be initialized to synchronize only threads in this process,
while {\tt lockflag = 2} means the lock
will be initialized to synchronize threads across processes.
For the POSIX thread package, {\tt lockflag != 0} means the lock
will be initialized to synchronize only threads in this process.
\par \noindent {\it Error checking:}
If {\tt lock} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsection{Utility methods}
\label{subsection:Lock:proto:Utility}
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Lock_lock ( Lock *lock ) ;
\end{verbatim}
\index{Lock_lock@{\tt Lock\_lock()}}
This method locks the lock.
\par \noindent {\it Error checking:}
If {\tt lock} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Lock_unlock ( Lock *lock ) ;
\end{verbatim}
\index{Lock_unlock@{\tt Lock\_unlock()}}
This method unlocks the lock.
\par \noindent {\it Error checking:}
If {\tt lock} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}