gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control systemdiff --git a/skripta-os2.tex b/skripta-os2.tex
--- a/skripta-os2.tex
+++ b/skripta-os2.tex
na Kubuntu 11.10 i 12.10 64bit.
\begin{codeblock}
-DEFINITION MODULE FOR "C" Lib32;
+DEFINITION MODULE FOR "C" libdir;
+
FROM SYSTEM IMPORT
ADDRESS, BYTE;
- EXPORT UNQUALIFIED opendir, readdir, closedir, stat,
- PDir, DirEnt, PDirEnt, Stat, PStat, PInt;
+
+ EXPORT UNQUALIFIED opendir, readdir, closedir, PDir, DirEnt, PDirEnt;
\end{codeblock}
-\begin{minipage}{0.5\textwidth}
+\begin{minipage}{0.45\textwidth}
\begin{codeblock}
(* types for 32 bit *)
TYPE
PDir = ADDRESS;
DirEnt = RECORD
- ino: INTEGER;
- off: INTEGER;
- reclen: SHORTCARD;
- type: BYTE;
- name: ARRAY [0..255] OF CHAR;
+ ino: INTEGER;
+ off: INTEGER;
+ reclen: SHORTCARD;
+ type: BYTE;
+ name: ARRAY [0..255] OF CHAR;
END;
PDirEnt = POINTER TO DirEnt;
- Stat = RECORD
- dev: LONGINT;
- ino: LONGINT;
- mode: INTEGER;
- nlink: LONGINT;
- uid: INTEGER;
- gid: INTEGER;
- pad1: LONGINT;
- rdev: INTEGER;
- size: INTEGER;
- blksize: INTEGER;
- blocks: INTEGER;
- atime: LONGINT;
- mtime: LONGINT;
- ctime: LONGINT;
- END;
- \end{codeblock}
+ \end{codeblock}
\end{minipage}
\begin{minipage}{0.45\textwidth}
\begin{codeblock}[frame=single,frameround=tttt]
TYPE
PDir = ADDRESS;
DirEnt = RECORD
- ino: LONGINT;
- off: LONGINT;
- reclen: SHORTCARD;
- type: BYTE;
- name: ARRAY [0..255] OF CHAR;
+ ino: LONGINT;
+ off: LONGINT;
+ reclen: SHORTCARD;
+ type: BYTE;
+ name: ARRAY [0..255] OF CHAR;
END;
PDirEnt = POINTER TO DirEnt;
- Stat = RECORD
- dev: LONGINT;
- ino: LONGINT;
- nlink: LONGINT;
- mode: INTEGER;
- uid: INTEGER;
- gid: INTEGER;
- pad1: INTEGER;
- rdev: LONGINT;
- size: LONGINT;
- blksize: LONGINT;
- blocks: LONGINT;
- atime: LONGINT;
- mtime: LONGINT;
- ctime: LONGINT;
- END;
- \end{codeblock}
+\end{codeblock}
\end{minipage}
\begin{codeblock}
- PStat = POINTER TO Stat;
- PInt = POINTER TO INTEGER;
-
PROCEDURE opendir(name: ARRAY OF CHAR): PDir;
PROCEDURE readdir(dirp: PDir): PDirEnt;
PROCEDURE closedir(dirp: PDir): [INTEGER];
- PROCEDURE stat(path: ARRAY OF CHAR; buf: PStat): [INTEGER];
-END Lib32.
+
+END libdir.
\end{codeblock}
\begin{codeblock}
-MODULE Zad5;
+MODULE Zad3;
-FROM SYSTEM IMPORT
- ADR;
FROM StrIO IMPORT
WriteString, WriteLn;
FROM NumberIO IMPORT
WriteInt;
-FROM StrLib IMPORT
- StrLen, StrConCat;
FROM Args IMPORT
Narg, GetArg;
-FROM Lib32 IMPORT
- opendir, readdir, closedir, stat, PDir, PDirEnt, Stat;
+ FROM libdir IMPORT
+ opendir, readdir, closedir, PDir, PDirEnt;
FROM errno IMPORT
geterrno;
VAR
dir: PDir;
entry: PDirEnt;
- info: Stat;
c: INTEGER;
- Len: CARDINAL;
- Putanja: String;
BEGIN
+ WriteString("Folder "); WriteString(Ime); WriteLn;
dir:= opendir(Ime);
IF dir = NIL THEN
- WriteString("Folder "); WriteString(Ime); WriteLn;
WriteString(" Greska broj "); WriteInt(geterrno(), 0); WriteString("."); WriteLn();
WriteString(" Ne mogu da otvorim direktorijum."); WriteLn();
ELSE
- Len:= StrLen(Ime);
- IF Ime[Len - 1] # "/" THEN
- StrConCat(Ime, "/", Ime);
- END;
- WriteString("Folder "); WriteString(Ime); WriteLn;
entry:= readdir(dir);
WHILE entry # NIL DO
IF entry^.name[0] # "." THEN
- StrConCat(Ime, entry^.name, Putanja);
- c:= stat(Putanja, ADR(info));
- WriteString(" ");
- IF c = -1 THEN
- WriteString("? ? KB");
- ELSE
- WriteInt(info.nlink, 3);
- WriteInt((info.size + 512) DIV 1024, 5); WriteString(" KB ");
- END;
- WriteString(" "); WriteString(entry^.name); WriteLn;
+ WriteString(" "); WriteString(entry^.name); WriteLn;
END;
entry:= readdir(dir);
END;
Listaj(Putanja);
END;
WriteLn;
-END Zad5.
+END Zad3.
\end{codeblock}
\subsection{Stvaranje novih procesa}
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
[proc/.style={circle,draw}]
-\def \n {5}
-\node[proc] (1) at (0,0) {1};
-\foreach \s in {2,...,\n}
+\def \n {3}
+\node[proc] (top) at (0,0) {0..4};
+\foreach \s in {0,...,\n}
{
- \node[proc] (\s) at (-3.5+\s,-2) {\s};
+ \node[proc] (\s) at (-1.5+\s,-2) {\s};
}
-\foreach \s in {2,...,\n} {
- \draw [->] (1) to (\s);
+\foreach \s in {0,...,\n} {
+ \draw [->] (top) to (\s);
}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
[proc/.style={circle,draw},
-level 1/.style={sibling distance=20mm,level distance=10mm},
-level 2/.style={sibling distance=10mm,font=\scriptsize}
+level 1/.style={sibling distance=28mm,level distance=10mm},
+level 2/.style={sibling distance=14mm,font=\scriptsize},
+level 3/.style={sibling distance=6mm,font=\tiny}
]
-\node[proc] (root) {0}
-child[->] foreach \x in {1,2} {node[proc] {\x}
- child foreach \y in {1,2} {node[proc] {\x-\y}
- }};
-
+\node[proc] (root) {1-0}
+child[->] foreach \x in {0,1} {node[proc] {1-\x}
+ child foreach \y in {0,1} {node[proc] {2-\y}
+ child foreach \z in {0,1} {node[proc] {3-\z}
+ }}};
+
+\node[text width=0.9\textwidth] (desc) at (0,-4) {maxdubina=4, potrebnodece=2,
+čvorovi prikazuju vrednosti pri kreiranju};
\end{tikzpicture}
\end{minipage}