Thursday, April 19, 2012

BSD-UNIX
university of california
bell labs
Time-sharing

clock algorithm / second chance algorithm
   circularly linked list
   walk incircle, check ref of pages (if set clear)
   if reach page wi/out reference, means it wasn't accessed so kill it
   second chance

  concurrency issues...

block devices - hard drives -
character devices - keyboard, mouse, /dev/null
sockets - pipes (named, unnamed), network socket ex. tcpip based ....

modem  = character device
freebsd = complete & free...

MOCK
//carnagie mellon
where all processes are in user space

microkernel root;

pg 125 dinosaur
   ports in mach (like mailbox)

NUMA

xNU = X (not unix) kerenel for mac
   freebsd but for mac
   from freebsd, took:
         process model,
        network stack,
       virtual file system

  from Mach, took kernel

Tuesday, April 17, 2012

RealTime

Real time is where computation has to be done by deadline

Hard Realtime vs. Soft Realtime
ex: windows or linux or bsd or solaris
      some kind of real time guarantee (not strong)
Hard realtime - embedded devices
EX walking robot adjust balance
   System on Chip

NVRAM  = power persists despite power outage. solid state drive 

Real Addressing mode
Logical address IS Real address

Relocation register
   just adds offset to real address

Lynx OS
priority inheritance and inversion
no on demand paging

Preemptive vs. Reentrant

all kernels are reentrant, but not all are preemptive
Preemptive will stop for something mid-task,
Reentrant just makes a note of something

for real time, should be preemptive
  preemptive lends itself to bugs like race conditions though.

priority based scheduling
n * ( 2 ^ (1/n) -1 )
where n is number of processes

Earliest deadline first
(….rate monotonic scheduling … ??)

Microkernel - one small kernel that does limited amount
basically just passes caller's request to function
work for realtime systems
ex: tinyOS


Wednesday, April 11, 2012

OpenBSD called me a Burrito Brain...

Only made root at first. Had to do the following to add smargonz user (openbsd)


adduser smargonz
sudo user mod -G wheel smargonz

http://www.bleepingcomputer.com/forums/topic127237.html
http://www.openbsd.org/faq/faq10.html#wheel
http://bsdsupport.org/2007/04/q-how-do-i-add-a-user-to-the-wheel-group-in-openbsd-or-netbsd/


Using emacs equivalent "mg" text editor.
      Shortcuts listed here: http://www.openbsd.org/cgi-bin/man.cgi?query=mg


Part 5 tip - use malloc, find when slow calls occur, count bytes between them.
      http://discuss.joelonsoftware.com/default.asp?interview.11.520685.12

Tuesday, April 3, 2012

Virtual File System
inode vs file descriptor
422         425

examples-
inode created for pipe put in fd

Contiguous allocation
    - block of hard drive allocated to file
    - not common, external frag is issue

Linked allocation
     - works like linked list
     - allocate blocks
     - read block, also read pointer to next block
     - can't randomly access file (have to trace it )
   linked allocation makes optimization difficult (different spots on disk so have to physically  move)

indexed allocation
     - Linked Scheme
              straightforward way, you know where blocks are
     - Multi Level Scheme
               like multi level page tables
               indices of indices
     - Combined Scheme  **LINUX**
             
...............................,,,,,.................
worry about concurrency
deadlocks

page cache block
      - 4kb blocks
Swap cache block
     - good way to avoid race conditions
     - try taking away each process's mapping then schedule out harddrive........errrr, what......
      - 4kb blocks

Buffer cache
     - not like other two @ 4kb chunks , chosen when formated hd
     - have to block read requests of user space processes til we know we have the blocks of data that we need
     - slower


===================
loop back device

dd copies raw bytes (careful, can screw up your disk)
     dd if=/dev/zero of=myhardriveimage.img bs=1024 count=81920
     makes 80 meg hardrive image of 1k blocks with input file if and output file of

sudo losetup /dev/loop0 mylhardrive.img
     loopback that allows us to pretent fils on other filesystem are devices themselves
   
journaling filesystem started with ext4 that tracks allocation of space to files
can go through journal if power is yanked, treat as atomic statements

ls /mnt/

sudo mount -t ext3 /dev/loop0 mnt/myfilesystem/
df -Th
         (gives info on filesystem)
cd mnt/myfilesystem/
sudo dd if=/dev/urandom mybigfile.bin
     (will eventually run out of space)

sudo debugfs /dev/loop0
ls
stat mybigfile.bin
    can see inode for mybigfile.bin
    inode number