Tuesday, January 31, 2012

Architecture Review - Rough Notes

Page tables & TLB & System Calls

32 bit virtual address :     10 --------10 ------------12------

if paging on in processor, every pointer has to be translated to physical address.
linux will create virtual address for physical if it doen't have one


ControlRegister3 (CR3) register is base of page table
change which virtual address we're in
CR3 protected (cant' change from user mode)
thread vs process - threads share addresses

"kernel level thread" = lightweight processes = share address space
when kernel changes from one process to another, changes cr3

for any process, first-level page table exists (4kb = 2 ^ 10, but each 4 bit word, 1024 entries)

How paging works:
first 10 bits used as index into first level pg table
first level - supervisor bit, user or kernel permission, valid bit,
everything done in lazy way - kernel won't put something in memory until absolutely necessary  
first level pg table is valid pointer to 2nd level pt table
get pointer out of second (if valid/accessible/etc) 

VM_struct
list of all diff pieces of virtual memory
page faults
expanding stack (3 pg tolerance)
bogus ptr
mapped memory - trying to write to library example - permissions
sbrk - system call to resize heap
if mapping gone (if process hasn't used process in long time, kernel writes a page back to disk)

thrashing 
os moving pages 

SWAP
ext4 filesystem


precise interrupts

stack grows backwards in virtual memory in x86


//////////

Table LookAside Buffer
Replaces need to look at page table (unless page fault)
x86 has to worry about what - 
have to flush it if switch to new process
virtual to physical address mappings aren't the same from process to process
some (not x86) can tag & choose to not use those TLB entries

Context Switches & System Calls
processor can give up cpu by doing system call
System Call
exception = specific to process 
interrupt = 

int(errupt) 0x80
paging system keeps user in 'is place!


Back to pg tables: 
"Copy on Write" - when you fork child, shares everything w/ parent (binary, permissions, etc)
makes separate pg table for each child.
optimization
when parent and child write to same page, shouldn't be able to see each others' writes

perl python ruby code usable
C

process scheduling
less /proc/588/maps  

look atthis to understand diff mem structures are & virtual space.

Tuesday, January 24, 2012

Notes

Jan 24, 2012 --------- OS

ssh [virtual machine ip address]

(not sure if installed ssh server so ->) sudo apt-get install open ssh
sudo apt-get install manpages-dev
sudo apt-get install linux-source

new screen -> control a c (?)
switch screen -> control a n

man screen
screen

ps axjf process tree
forth # gives pid
second to last on right is user id (who initiated process)

processes just create children
children run binary of process

first binary in memory is init binary, run in user space (always run as root)
child inherits privileges of parent

sudo su - 

gives root@ubuntu:~#
login binary is child of init

ps -el | grep init
exit 

exits root
daemon = process that runs in background
sshd = ssh daemon

etsy

UID
effected UID
real UID

once root priv gone, use SUID bit or use child of root 

man strace

gdb uses ptrace 
clone does work for strace

"free bsd jails"

strace -p pid -o /tmp/my.strace -ff 
ls -la | sort

man 2 pipe gives you pg 2 of manual (system calls)

less my.strace……?

pipe values should correspond to underlying system call

ls -l /proc/PID/maps
sudo ls -l /proc/sys/net/ipv4/tcp_syncookies

proc is a way of looking inside kernel w/o being kernel 
file /bin/bash
man nm -lists symbols from object files

stripped means debug info stripped out
linker and loader

.data 
.heap 
.stack
.tex -- executable goes



one virtual space for one process
why oxc000000 does kernel start there?
pipe and clone



Reaing - chapters 1 & 2 of bovey and suzadi 

how x86 helps linux manage process


http://en.wikipedia.org/wiki/Less_(Unix)

Wednesday, January 18, 2012

Things That Worry Me

A list of items mentioned in lecture that worry me: 


  • Headless mode
  • RDP connection
  • ext4 filesystem
  • DHCP

Assignment 0.0 -- Virtual Box and Ubuntu

PREP IT:
  • Download and install VirtualBox
  • Download Ubuntu Server 10.04 (32 bit version)

DO IT:

  • Create new Virtual Machine
  • Highlight VM
  • Settings
  • Storage
  • SATA-> Use host i/o cache
  • IDE Controller -> Empty
  • Click CD symbol
  • Host a Virtual CD/DVD file
  • Select .iso
    • OK
  • Start up VM
  • INSTALL IT!!!

ICE IT:

  • Put emacs on it
    • sudo apt-get install emacs
  • Poke around
    • cd /usr/sbin
    • ls | more

::: Resources ::: 
VirtualBox
UBUNTU
This tutorial proved useful.

ECE 437 Blog

The purpose of this blog is to document my progress on labs and understanding OS concepts. I will blog in a tutorial format with the firm belief that my virtual machine will inevitably die a horrible horrible death. Hopefully this will make life less painful for my future self when I have to rebuild from the ruins.



That being said, a few notes:

To Create SVN Repository:
     http://www.cs.unm.edu/computer_facilities_and_support/subversion/

To Check Out SVN Repository :
     svn co svn+ssh://smgonzal@linux.unm.edu/nfs/user/s/smgonzal/svnrepository