CS 3210 Design of Operating Systems
College of Computing, Georgia Tech
Lecture 2: Tuesday 18 January 2000
Program 1 / Board Checkout / Team Signups
A First Look at the Code (Maxwell Ch 2): printk()
announcements
- roll
- photos
- handouts: p1
- board checkout / team signups
a first look at the code
- gcc-specific features (inline, expression blocks, optimization)
- gotos! (1 per 80 lines)
kernel coding style/idioms
- error variable idiom
- resource acquisition idiom (locking, unlocking)
- reduced use of #if and #ifdef
- platform dependencies isolated in separate functions/macros
- no compiler dependencies
- some truly conditional code (SMP, etc.)
looking at source
- understand basic functionality (semantics)
- scan file for functions, global data
- read the comments :-)
kernel/printk()
- kernel printf
- log-levels 0-7 ("<6> Blah blah blah")
- maintains a 16k circular log_buf for recent stuff
- console(s) register drivers
- printks possible before consoles registered!
- "flushes" on NEWLINE
- stdargs: va_start, va_end
- spinlock macros
- wait queue: wake_up_interruptible(&log_wait)
- optimizations?
- syslog, dmesg, syslogd, klogd, /proc/kmsg
wait queues
- queue of struct task_struct
- #define wait_event(wq, condition)
- do { ... } while(0); idiom
- #define wait_even_interruptible(wq, condition)
- gcc expressional block feature ({...})
kernel modules
- dynamically linked/loaded kernel segments
- somewhat simplified interface to kernel proper
- may statically link modules
- + independent compilation
- can be dynamically removed
- kerneld ==> now kmod
configuring / building the kernel
- make config, menuconfig or xconfig
- ==> result is .config (CONFIG_SMP=y etc.)
- don't alter configuration for now!
- make dep
- make zImage (zdisk, zlilo, bzimage, etc.)
- make clean (archclean, distclean, mrproper)
- see Linus' README for more details...
readings for next thursday (20 jan 2000)
- Maxwell Ch 4 Booting
- Beck Ch 3.2.3, Appendix D Booting
- Rubini Ch 16 Kernel Source Tour, Booting