COMP 3000 2012 Week 3 Notes: Difference between revisions

From Soma-notes
Sdp (talk | contribs)
Added second lecture
Cdelahou (talk | contribs)
→‎Why we're studying unix: added a few points
Line 47: Line 47:
== Why we're studying unix ==
== Why we're studying unix ==


* all operating systems have basically the same architecture
* all operating systems have roughly the same architecture
* windows is just a variation on unix
* windows is just a variation on unix. Built and designed very similarily.
* "Like a different accent. Same everything, but renamed"
* Slight differences in the way things are done
** Example: On Unix, configs reside in flat text files. In Windows, they live in an opaque key/value store called the registry.
 
Despite the similarities between OS families, Unix systems tend to be built much more transparently, which makes it a good vehicle to study OS topics
 
* windows comes from vms
* windows comes from vms
** increment(vms) -> wnt
** increment(vms) -> wnt

Revision as of 18:20, 24 September 2012

Shell

  • useful command line programs
    • bc -l
      • command line calculator
    • cal
      • command line calendar
    • uniq
      • filters out duplicate lines
    • sort
      • takes input on STDIN, sorts lines, prints to STDOUT
  • vmlinux is the linux kernel with virtual memory [vmlinux]
    • vmlinuz is the same but compressed
  • bash runs on vmlinux
    • most programs run on bash
    • ls/cd also run on vmlinux
    • ls runs as a child process of bash
  • to get rid of a misbehaving child
    • the parent must kill it
    • waits for child to die
    • an unreaped child becomes a zombie
    • zombies can't be killed, must be reaped
    • to kill a zombie, must kill parent
    • orphans become a child of init (ward of state)
    • init is good at reaping children

job control

  • job is a process
    • term comes from batch processing
  • Useful control sequences
    • Ctrl-C
      • terminate job
    • Ctrl-Z
      • stop job
  • To start a stopped job in the foreground
    • fg %n
      • where n is the job number
  • To start a stopped job in the background
    • bg %n
  • To determine jobs that are running
    • jobs
  • Who manages jobs?
    • the shell
    • built on kernel functionality

Why we're studying unix

  • all operating systems have roughly the same architecture
  • windows is just a variation on unix. Built and designed very similarily.
  • "Like a different accent. Same everything, but renamed"
  • Slight differences in the way things are done
    • Example: On Unix, configs reside in flat text files. In Windows, they live in an opaque key/value store called the registry.

Despite the similarities between OS families, Unix systems tend to be built much more transparently, which makes it a good vehicle to study OS topics

  • windows comes from vms
    • increment(vms) -> wnt

Init and Shell Scripts

Guest mini-lecture by Ann Fry

  • /etc/init.d/
  • initialization scripts
  • examples
    • /etc/init.d/networking [start|stop]
    • /etc/init.d/networking [start|stop]
  • shell scripts
  • start with
    • #!/bin/bash
    • #!/bin/csh
    • #!/bin/ksh

Ann passes the lecture to Anil Somayaji

  • Init scripts
  • Traditional init scripts run sequentially
  • Modern init scripts run in parallel
  • executables
  • ELF
  • A file starting with #!
    • next comes the path to an interpreter for the rest of the file
  • common directories
  • /etc
    • pronounced ett-see
    • configuration
    • different subdirectories
    • /etc/<prog>.conf
    • /etc/<prog>/Sdp
    • /etc/<prog>.d/Sdp
  • /bin
    • system binaries
    • often this is local
  • /lib
    • system libraries
  • /home
    • user directories
  • /usr
    • often this is shared
    • /usr/bin
    • user binaries
    • /usr/lib
    • user libraries

History of Unix

  • In the beginning, there was AT&T's Unix
  • AT&T gave site licenses with all the source
  • Berkeley developed networking (at least TCP/IP) called BSD
    • licensed under permissive BSD license
  • AT&T forked System V
    • Not permissively licensed
  • Sun created hardware to run unix and forked SunOS from BSD
  • Sun changed from SunOS (BSD) to Solaris (System V)
    • people disliked this
  • POSIX standard was an outcome of the fragmentation
  • Free Software Foundation came out of the fragmentation
    • founded by rms (Richard M. Stallman)
    • not initially a very open development environment
    • built all the components of unix called GNU (GNU's Not Unix)
    • yacc -> bison
    • more -> less
    • cc -> gcc
  • Anil was sysadmin for a crystalography lab
    • SGI IRX boxes
    • ran IRIX
  • 80386 came out
    • capable of running a real unix because of virtual memory
    • legal status of BSD kernel became an issue because of lawsuit
    • GNU started Hurd
    • Linus Torvalds writes Linux kernel
    • uses GNU license
    • allowed everyone to make contributions
  • Eventually BSD legal stuff got figured out
    • 386BSD
    • FreeBSD
    • NetBSD
      • OpenBSD
  • Anil's opinion
  • Linux has the best driver support of any OS including Windows

Back to Init

  • Why do we care?
  • Unix is a culture
  • the culture shows up all over, like in /etc, /etc/init.d
  • Now there are 3 major replacements for system V init scripts
  • system V init scripts are just shell scripts run sequentially
  • it's desirable to run the initialization in parallel
    • oh noes, race conditions
    • init scripts have dependencies!!
  • init scripts were ordered by convention
    • had to figure out all the dependencies
    • still not completely figured out
  • everything on linux is an open source project
  • look around for a good project to document


References

^ : https://en.wikipedia.org/wiki/Vmlinux