X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?a=blobdiff_plain;f=skripta-os2.tex;h=f74696f9390bcbf7937a8081425f0fb779cff4c4;hb=e148eb56fab9e6c7cb759a8fdc686202382f199f;hp=47030ea6ad025c2fafd6e0afbb049f7a80104438;hpb=187514428a7abca8c19610bebcde1c2c14173eb8;p=os2skripta.git diff --git a/skripta-os2.tex b/skripta-os2.tex index 47030ea..f74696f 100644 --- a/skripta-os2.tex +++ b/skripta-os2.tex @@ -383,46 +383,31 @@ Budući da su u pitanju sistemski pozivi niskog nivoa, veličine tipova su nažalost promenljive i mogu zavisiti od konkretnog operativnog sistema, a naročito utiče da li je u pitanju~32--bitni, ili~64--bitni sistem. Zbog ovoga su date dve varijante bibilioteke sa tipovima. -Prva je testirana na Lubuntu 11.10 32bit, a druga je testirana na -Kubuntu 11.10 64bit. +Prva je testirana na Lubuntu 11.10 i 12.04 32bit, a druga je testirana +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] @@ -430,57 +415,34 @@ DEFINITION MODULE FOR "C" Lib32; 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; @@ -496,35 +458,18 @@ PROCEDURE Listaj(Ime: ARRAY OF CHAR); 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; @@ -544,7 +489,7 @@ BEGIN Listaj(Putanja); END; WriteLn; -END Zad5. +END Zad3. \end{codeblock} \subsection{Stvaranje novih procesa} @@ -634,14 +579,14 @@ END; \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} @@ -650,15 +595,16 @@ END; \begin{minipage}{0.6\textwidth} \begin{codeblock} -i := 1; -j := 0; -WHILE (i < n) AND (j < m) DO +dubina := 1; +brdece := 0; +WHILE (dubina < maxdubina) AND + (brdece < potrebnodece) DO pid := fork(); IF pid # 0 THEN - INC(j); + INC(brdece); ELSE - INC(i); - j:=0; + INC(dubina); + brdece := 0; END; END; \end{codeblock} @@ -666,14 +612,18 @@ END; \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}