divzeroweb

2f30.org website
git clone git://git.2f30.org/divzeroweb
Log | Files | Refs | README | LICENSE

lecture0.shtml (6582B)


      1 <h3>Introduction to computation, hardware and UNIX</h3>
      2 
      3 <h4>Turing Machines</h4>
      4 <p>
      5 A theoretical machine that performs actions on an infinite tape.
      6 These actions
      7 </p>
      8 <ol>
      9 <li>Can be determined by the value of the symbols on the tape.</li>
     10 <li>Include at least: reading/writing of the tape symbols,
     11 printing symbols.</li>
     12 </ol>
     13 <p>
     14 In the above context
     15 the first introduces the "configuration" parameters, and
     16 the second introduces the "behaviour" at a given "configuration".
     17 The group of all the configurations and their transitions is called
     18 the state transition table, and if drawn as a diagram, it is called
     19 the state transition diagram.
     20 </p>
     21 <img src="resources/turing.png" alt="Universal Turing Machine">
     22 <p>Some examples follow.
     23 In the format STATE, READ, DO, GO (P means Print, * means anything).
     24 </p>
     25 
     26 <p>A machine that writes 0s:</p>
     27 <pre>
     28 s1, *, P0, s1
     29 </pre>
     30 
     31 <p>A machine that writes 0s and 1s:</p>
     32 <pre>
     33 s1, *, P0, s2
     34 s2, *, P1, s1
     35 </pre>
     36 
     37 <p>A tape negator (means it does 100100110001 -> 011011001110):</p>
     38 <pre>
     39 s1, 1, P0, s3
     40 s2, 0, P1, s3
     41 s3, *, R, s1||s2
     42 </pre>
     43 <p>(means s1 OR s2, since it depends on the next symbol)</p>
     44 
     45 <h4>Universal Turing Machines</h4>
     46 <p>
     47 We said that since these state transition tables, can be written on
     48 the tape, we could create a machine that has 2 tapes; from one we
     49 read the instruction (program code) and on the other one we execute it.
     50 therefore we have a Turing machine that can 'run' other machines.
     51 The Turing machine, that can run all possible other machines, is called a
     52 Universal Turing Machine.
     53 </p>
     54 
     55 <h4>Understanding the relation to modern computers</h4>
     56 <p>
     57 To have a "computer" we need at least a CPU and some kind of memory.
     58 Then the relation is straightforward.  Code running on the CPU is
     59 the state transition table, which accounts for the "behaviour" of the system.
     60 Memory takes the place of the infinite tape, which determines
     61 (by what it contains) the "configuration" of the system.
     62 </p>
     63 
     64 <h4>Operating Systems</h4>
     65 <p>
     66 In this context what can an operating system be?
     67 Well, it is EVERYTHING between this previous image of a "computer" and
     68 what you experience in everyday life.
     69 This means, it is up to the operating system to introduce and
     70 implement the way that you control the machine.
     71 It is what connects your idea of a FILE object named myfile that you can
     72 myfile.open(), myfile.read(), myfile.delete(), myfile.write().
     73 But as you can imagine, for this to be implemented we need to connect
     74 two pretty different things:
     75 </p>
     76 <ul>
     77 <li>The code that says:
     78 <em>What IS a file?  Where does it live?  What can I do on it?</em></li>
     79 <li>The code that does:
     80 <em>SIGNAL: HARD DISK ACESS AT *0xD474, READ 0xF BYTES.</em></li>
     81 </ul>
     82 <p>
     83 And this mess is just for simple files ;)
     84 </p>
     85 
     86 <h4>UNIX</h4>
     87 <p>
     88 Well the UNIX engineers (most notably Ken Thompson, Dennis Ritchie, Bill Joy)
     89 understood, that in order to bring such a diverse pair close, they needed
     90 Abstraction by Interfaces.  This is actually a DESIGN PATTERN found not only
     91 in computer programs, but in nature also (Societies, Simple Machinery, onions?).
     92 So they designed UNIX to be a Multi-User, Multi-Tasking, Structured
     93 Operating System.
     94 </p>
     95 <ul>
     96 <li>
     97 Multi-User means that by introducing the notion of different users
     98 you bring security into play (remember the non-secure-windows example).
     99 </li>
    100 <li>
    101 Multi-tasking means that you simulate the parallel execution of
    102 <em>stuff</em>(TM) therefore keeping <em>users</em>(TM) happy! ;)
    103 For example, you can watch a movie while reading your e-mail,
    104 although on a single-processor system only one operation is performed at a
    105 cycle (well more or less...).
    106 </li>
    107 <li>
    108 Structured means it gets easy to operate on it,
    109 since the way it is structured provides extra information about it.
    110 </li>
    111 </ul>
    112 <img src="resources/layers.png" alt="OS layers">
    113 
    114 <h4>The Unix Filesystem</h4>
    115 <p>
    116 The UNIX  filesystem controls the way that information in files and
    117 directories is stored on disk and other forms of secondary storage.
    118 It controls which users can access what items and how.
    119 The filesystem is therefore one of the most basic tools for enforcing
    120 security on your system.
    121 </p>
    122 <p>
    123 Information stored in the UNIX filesystem is arranged as a tree structure
    124 of directories and files.  The tree is constructed from directories and
    125 subdirectories within a single directory, which is called the root.
    126 Each directory, in turn, can contain other directories or entries such as
    127 files, pointers (symbolic links) to other parts of the filesystem,
    128 logical names that represent devices (such as <em>/dev/tty</em>),
    129 and many other types.
    130 Remember!  Everything in UNIX is a file, so you can do pretty cool things...
    131 (like reading thermal data from a sensor device (an external thermometer)
    132 by using the <em>cat</em> command (which just prints a file)
    133 on the device file that represents the thermometer
    134 (let's say it is <em>/dev/sensor2</em>).
    135 Then we would do <code>cat /dev/sensor2</code> and the command would print the
    136 temperature as reported by the thermometer, in a human readable format).
    137 </p>
    138 
    139 <h4>Some programs to get you started (with examples)</h4>
    140 <p><strong>ls</strong>: List contents of directory</p>
    141 <pre><code>% ls -al
    142 % ls -alh
    143 % ls -al /bsd
    144 </code></pre>
    145 <p><strong>man</strong>: Prints manual of other commands</p>
    146 <pre><code>% man ls
    147 % man ssh
    148 % man man
    149 </code></pre>
    150 <p><strong>cd</strong>: Change directory</p>
    151 <pre><code>% cd /etc
    152 % cd /home/user # which is also cd ~, or just cd
    153 </code></pre>
    154 <p><strong>pwd</strong>: Print working directory</p>
    155 <pre><code>% cd /var
    156 % pwd
    157 /var
    158 </code></pre>
    159 <p><strong>cp</strong>: Copy a file</p>
    160 <pre><code>% cp myfile newfilecopy
    161 % cp -r mydir/ mynewdir/
    162 </code></pre>
    163 <p><strong>rm</strong>: Remove a file</p>
    164 <pre><code>% rm oldstupidfile
    165 % rm -rf oldstupiddirectory/
    166 </code></pre>
    167 <p><strong>ps</strong>: View system processes</p>
    168 <pre><code>% ps -ax # view all processes
    169 % ps -xU luser # only luser's procs
    170 </code></pre>
    171 <p><strong>more</strong>: Read a file</p>
    172 <pre><code>% more mytext # view mytext, press space for next page
    173 </code></pre>
    174 <p><strong>grep</strong>: Search for something somewhere</p>
    175 <pre><code>% grep Password secretfile # find if secretfile contains the word Password
    176 </code></pre>
    177 <p><strong>su</strong>:	Become super-user (or another user)</p>
    178 <pre><code>% su # need to enter root password
    179 % su - userA # become userA
    180 </code></pre>
    181 
    182 <p>
    183 Have a gift!
    184 A <a href="http://www.levenez.com/unix/unix_a4.pdf">poster</a> filled
    185 with history!  Taken from
    186 <a href="http://www.levenez.com/unix/">Éric Lévénez</a>.
    187 </p>
    188 
    189 <p>Happy Hacking...</p>
    190 <p>dsp@</p>