ECS 150 Operating Systems TA Notes (Fall 2006)


Office Hours

3104 Kemper Hall
Wed 12:00 - 1:30pm
Thr 3:00 - 5:30pm

Discussion Notes

Discussion 1 - Compiling/Installing FreeBSD
Discussion 2 - Homework 1 notes
Discussion 3 - Homework 2 notes
Discussion 4 - Homework 2 notes

Using Virtual Machines

Virtual PC Shared Folders work only with the guest OS additions (FreeBSD does not have it).
For the life of me, I can't get the VM'd FreeBSD to read the USB key (Maybe its just Virtual PC and me).

Using FreeBSD 5.4

vi is your friend.
pwd - know where you are.
Don't know "something"? Try "man 'something'"
dmesg - See the system message buffer
kldstat, kldload, and kldunload - How to load modules

Getting ssh/sftp/scp to work

  1. Make sure the sshd service is turned on. ( ps aux | grep sshd ) If it shows only "grep sshd" and no other line, then it's not on.
  2. To turn on sshd, run "/etc/rc.d/sshd start"
  3. Use "ifconfig" to check your adapter name. (should not be lo0, plip0), (should be something like de0)
  4. Then, do "ifconfig <adapter> up" to bring up the interface
  5. Finally, run "dhclient <adapter>" (assuming your computer is connected to a dhcp-enabled network)
  6. If it works, you should have an IP address for the guest OS and you can communicate between your host OS and it!
  7. If you only have the root account, make sure you change the /etc/ssh/sshd_config file to allow root access (uncomment "PermitRootLogin yes"), and restart sshd (/etc/rc.d/sshd start)

On Tracing Systemcalls

Try reading the files "/sys/i386/i386/exception.s" and "/sys/i386/i386/trap.c"

On tracking user and kernel space printf

OKay, for those really curious on how printf really differs,

You can trace the code:

Kernel Printf (/sys/kern/subr_prf.c)
Read kernel source


User Printf (from libc)

Go here to get all the slib.* files
ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/i386/5.4-RELEASE/src/install.sh

Run the following command to unpack them.
# cat slib.?? | tar --unlink -xpzf - -C .

It should create a lib/libc/ directory
Look in stdio and stdlib (remember those header files in your usr progs??)


Now you should have all the src to do the comparison properly.
Remember, we don't need too much details on this part, just enough so you know how they are both working (i.e. what funcs they call, and how they get into the kernel, if needed) 

Homework

Homework 1 Stuff

Makefile
Kernel Module Sample
Userspace program to use Kernel Module Sample
Homework 1 Tester (user program)
Homework 1 Tester 2 (user program)If you get 2 PASS, you win!, if you get any FAILURE, you better check your program...

Homework 2 Stuff

fork.c Example of fork()
pipe.c Example of pipe()
signal.c Example of signals (sigaction/kill)
NEW!!!
lottochk A lottery scheduler checker; runs like top (sort of)
Instructions:
1) Run it like any executable (make sure the permissions are correct i.e chmod 755 lottochk)
2) Commands allowed in interactive mode:
2a) l - toggles the lottery mode on or off
2b) c - creates a new process to run (it loops forever)
2c) x <tickets> <pid>- give that many tickets to a process PID
2d) k <pid> - kill a given PID
3) On your screen, when lottochk runs, look at the TKT column as the tickets, the PID for the pid and CPU/WCPU for the ratios
4) Only the lines with COMMAND as top are the ones that are created by 'c'
5) Enjoy, post all questions on the newsgroup, and not directly to me about this program
NEWER!!
l2 Another lottery checker, (scripted, not interactive). Takes two values (not command line) (number of procs to spawn and time to run).
NEWEST!!
wait4.c Sample for using wait4.c

Homework 3 Stuff

You asked for it, so here's the sharechk.tar.gz. Instructions on a post in newsgroup.
NOTE: Please Please Please DO NOT use this for your user program checker.

This is for you to test your share process tickets.

Untar it, and then go into the ./usr.bin/top directory

do a "make" (maybe even a make clean first)

	The executable is "top"
	run it with ./top


	It is an extension to the old one, so
	c for creating a new process
	x tickets pid  for set tickets
	l for toggling lottery mode
	z tickets spid dpid shares the tickets
	v spid dpid retrieve process tickets


	DISCLAIMER: Use this at your own risk, I haven't tested it, and I'm not sure if I can test it.  Please do let me know if its broken, so I can fix it.

Homework 4 Bonus Homework!!!

Bonus Homework

Misc

My Opinion on Studying Operating Systems

Get your hands dirty!
Read the kernel source to see how things are implemented (Ever wonder what happens when you call read()/write()?)
Read header files first (i.e. /sys/sys/proc.h) to see what structures are used in the OS.
Always check the man pages for functions and ideas. (i.e. "man pfind", "man kld")

Comments/Feedback:

This is my first time TAing a class. So ANY comments (good and bad) are welcome.
I take critical comments better than "You suck!" though.
You can let me know directly or anonymously (by telling the Prof. and have him tell me).
Also, please please please please please come to office hours, or I'll be twiddling my thumbs the whole time.

Links

Online Kernel Source (for those that hate reading in console mode)