CS 635: Advanced Systems Programming (Spring 2005)
Lecture: Monday-Wednesday 7:30pm-9:15pm (235 Harney Science Center)
Instructor:
Allan Cruse
cruse@usfca.edu
Phone: (415) 422-6562
Office: 212 Harney Science Center
Office Hours: (see my homepage)
- Focuses on Open Source Linux operating system for Intel Pentium processors
kernel version 2.6
- Assumes familiarity with C/C++ programming language,
x86 machine architecture, Unix operating
system commands,
and standard data-structures and algorithms (e.g., CS 112/210/245/326)
- Open to USF Graduate Students
(and to qualified undergraduates with instructor permission)
List of planned course topics:
- Shared runtime libraries
- Loadable kernel modules
- Asynchronous input/output
- The '/proc' and 'ext2' filesystems
- Character and Block Device-Drivers
- System data-structures and algorithms
- Kernel threads, timers, and wait-queues
- Interrupts, Exceptions, and System-Calls
- IA32 Symmetric Multiprocessing architecture
The course includes lectures, readings, discussions, demonstrations and programming projects.
Course Textbooks:
Learning Outcomes:
- You will be able to read and write code-modules for an operating system
- You will be able to implement customized extensions to the Linux kernel
- You will be able to craft your own tools that let users control their PC
- You will be able to identify system features that impact performance
Resources
Readings
- Week 1: Chapters 1 and 2 in "Linux Device Drivers" text
- Week 2: Chapter 3 in "Linux Device Drivers" text
- Week 3: Chapter 3 in "Linux Kernel Programming" text
- Week 4: Chapter 4 in "Linux Kernel Programming" text
- Week 5: Chapter 6 in "Linux Device Drivers" text
- Week 6:
ATA/ATAPI-5 rev 3 Standard (Feb 2000) under 'Project Drafts'
- Week 7: Chapter 4 in "Linux Device Drivers" text
- Week 8: Chapter 5 in "Linux Device Drivers" text
- Week 9: Chapter 7 in "Linux Device Drivers" text
- Week 10: Chapter 8 in "Linux Device Drivers" text
- Week 11: Chapter 10 in "Linux Device Drivers" text
- Week 12: Chapters 9 and 11 in "Linux Device Drivers" text
- Week 13: Review Chapter 6 in "Linux Device Drivers" text
- Week 14: No new reading assignment; work on finishing Project 2
Handouts
- 0203-635-01: Course syllabus(.PDF)
- lesson1.ppt (PowerPoint Slides)
- Developer tool: newmod.cpp
creates the 'boilerplate' source-code for a new Linux kernel module
- Developer tool: mmake.cpp
automates the compilation of module-sources in the current directory
<--- revised 3/19/2005
- lesson2.ppt (PowerPoint Slides)
- Developer tool: newinfo.cpp
builds the skeleton for a module that will create a '/proc' pseudo-file
- Demo module: cr4.c
creates a pseudo-file (named '/proc/cr4') that displays system-register CR4
- lesson3.ppt (PowerPoint Slides)
<--- revised 02/05/2005
- Demo module: jiffies.c
creates a pseudo-file that lets users read the current value of 'jiffies'
- Developer tool: howfast.cpp
shows how you can measure the rate at which 'jiffies' increments
- Demo module: dram.c
character-mode device-driver for reading the processor's physical memory
- Developer tool: fileview.cpp
displays file (or device) contents in hexadecimal and ascii formats
<--- bug fixed 8/27/2005
- lesson4.ppt (PowerPoint Slides)
- Demo module: pageinfo.c
creates a pseudo-file showing sizes of fields in a 'struct page' object
- lesson5.ppt (PowerPoint Slides)
- Demo program: whereami.cpp
shows the virtual address where its own 'main()' function resides
- Demo program: kmapsnow.cpp
can show a dynamic display of the kernel's volatile pkmap_page_table
- Demo module: init_mm.c
this pseudo-file shows the physical address of the 'init' task's page-directory
- lesson6.ppt (PowerPoint Slides)
- Demo module: tasklist.c
creates a pseudo-file that shows a listing of all the system's active tasks
- lesson7.ppt (PowerPoint Slides)
- Demo module: mm.c
creates a pseudo-file showing information from a task's 'mm_struct' object
- Demo module: vma.c
creates a pseudo-file that shows a task's list of 'vm_area_struct' objects
- Demo program: domalloc.cpp
examines the effect of 'malloc()' on a task's kernel data-structures
- Exercise solution: dofork.cpp
examines the effect of 'fork()' on the list of 'vm_area_struct' objects
- Demo module: footprint.c
shows hows much memory is mapped into a program's address-space
- Exam solution: codesize.c
shows the total size for all Virtual Memory Areas that are 'executable'
- lesson8.ppt (PowerPoint Slides)
- Demo module: mbr.c
character-mode device-driver for reading the Hard Disk's Master Boot Record
- lesson9.ppt (PowerPoint Slides)
- Demo module: hdtraps.c
creates a log of all attempts to access the IDE Command/Status Register
- lesson10.ppt (PowerPoint Slides)
- Demo module: earlymbr.c
confirms that it is possible to read the MBR during module-inilization
- lesson11.ppt (PowerPoint Slides)
- Demo module: vram.c
character-mode driver for reading and writing to the video display memory
- Demo program: vramdraw.cpp
exercises the read(), write(), llseek() functions in our 'vram.c' driver
- Exam solution: serialno.c
creates a pseudo-file that shows the Hard Disk's unique serial number
- Demo module: ide_lock.c
shows module syntax for accessing the global 'ide_lock' kernel variable
- Demo module: updown.c
shows module syntax for access to the 'ide_cfg_sem' kernel semaphore
- lesson12.ppt (PowerPoint Slides)
- Demo module: vramm.c
enhances our 'vram.c' device-driver by implementing a 'mmap()' method
- Demo program: vrammdraw.cpp
new version of 'vramdraw' accesses video memory from user-space
- Demo program: grabber1.cpp
example-program (from Exam II, Question IV) using our 'vram.c' driver
- Demo program: grabber2.cpp
faster version of 'grabber1.cpp' program, using students' suggestions
- lesson13.ppt (PowerPoint Slides)
- Demo module: ioctl.c
a character-mode device-driver that implements two 'ioctl' services
- Demo program: tryioctl.cpp
this application invokes the 'ioctl' services of our 'ioctl.c' driver
- lesson14.ppt (PowerPoint Slides)
- Demo module: utsinfo.c
shows how a module can find out the name of the node it is running on
- Demo module: stash.c
illustrates the use of 'sleeping' and 'waking' in a character device-driver
- Demo module: announce.c
shows how a kernel module can send messages to the current console
- lesson15.ppt (PowerPoint Slides)
- Demo module: newstash.c
uses kernel semaphores to remove 'race conditions' observed in 'stash.c'
- Demo module: trytimer.c
illustrates the use of a dynamic kernel timer
- Demo module: tryworkq.c
illustrates the use of a workqueue for scheduling a future action
- Demo module: defermsg.c
uses a workqueue to delay the appearance of a message for ten seconds
- Demo module: foo.c
a very simple device-driver that lets applications read 'jiffies_64'
- Demo program: watchfoo.cpp
a program that tries to continually show the current 'jiffies_64' value
- Exercise solution: timedfoo.c
this driver uses a kernel timer to curtail the frequency of 'read()' calls
- lesson16.ppt (PowerPoint Slides)
- Demo module: mmap8139.c
this driver lets applications map the RTL-8139 registers to user-space
<--- revised on 10/24/2006
- Demo program: nicregs.cpp
it displays the current contents of all the RTL-8139 device registers
- lesson17.ppt (PowerPoint Slides)
- Developer tool: rxtester.cpp
it displays the raw packets sent to this workstation's network interface
- Demo module: user8139.c
an enhancement of 'mmap8139.c' that affords access to a kernel buffer
- Demo program: nicstudy.cpp
an enhancement of 'nicregs' that lets us study the NIC from user-space
- lesson18.ppt (PowerPoint Slides)
- Database template: ethers
for Ethernet-address to IP-address Database in the USF Kudlick Classroom
- Demo program: tryarp.cpp
revises our 'nicstudy' demo so as to transmit a useful ARP request-packet
- lesson19.ppt (PowerPoint Slides)
- Demo module: receiver.c
initial prototype for an RTL-8139 character-mode driver using interrupts
- Demo program: nicread.cpp
an application that reads packets using our 'receiver.c' driver prototype
- Exam solution: mac.c
creates a pseudo-file named '/proc/mac' showing the RTL-8139 MAC address>
- lesson20.ppt (PowerPoint Slides)
- Demo program: roomview.cpp
displays a view of our Kudlick Classroom's thirty computer workstaions
- Demo program: arpquery.cpp
sends ARP requests to stations on the local subnet and gathers replies
- Demo module: rxplustx.c
character-mode device-driver required by our 'arpquery.cpp' demo-program
- Demo program: highlite.cpp
shows a use of the 'terminfo' database to achieve a special video effect
- lesson21.ppt (PowerPoint Slides)
- Demo module: withpoll.c
revision of our 'rxplustx.c' device-driver so as to incorporate a 'poll()' method
- Demo program: multplex.cpp
illustrates use of the 'select()' function when handling multiplexed input
- Demo program: trychat.cpp
for demonstrating the feasibility of our proposed 'nicchat.cpp' project
- lesson22.ppt (PowerPoint Slides)
- Demo program: pipedemo.cpp
demonstrates handling of multiplexed input using asynchronous notification
- Demo module: nicasync.c revises
our 'withpoll.c' driver so it could support asynchronous input-notification
<--- bug fixed 4/29/05
- Exercise (partial-solution): nicasync.cpp
implements asynchronous input-notifications with our network interface
- Exercise (full-solution: nicasync.cpp
revises 'trychat.cpp' to use asynchronous notifications for multiplexed-input
- lesson23.ppt (PowerPoint Slides)
- Function revision: wrapfix.c corrects
an omission in the 'read()' method of our previous RealTek-8139 drivers
- Function addition: syncfix.c
supplies 'flush()' and 'fsync()' methods for our earlier RealTek device-drivers
<--- bug fixed 5/04/05
- Developer tool: sendback.cpp
continually reads our '/dev/nic' file and sends back the packets it recognizes
- Developer tool: echotest.cpp
writes random packets to '/dev/nic' and checks that they are correctly echoed
- lesson24.ppt (PowerPoint Slides)
- Demo module: nicports.c
allows applications to read the current contents of all the RealTek 8139 registers
- Demo program: watchnic.cpp
continuously rereads '/proc/nicports' to show a dynamic view of the registers
- Demo module: nictimer.c
this is a limited-purpose device-driver -- useful for studying the RT-8139's timer
- Demo program: 2seconds.cpp
uses the 'nictimer.c' driver to measure how rapidly the timer-count increments
- lesson25.ppt (PowerPoint Slides)
- Demo program: syswrite.cpp
showing how an application can issue a system-call directly to the Linux kernel
- Demo module: newcall.c
replaces the code for an obsolete system-call with our own kernel function
- Demo program: try17.cpp
this program can be used for testing our new system-call implementation
- Demo module: myexport.c
this module can 'export' the address of the kernel's 'sys_call_table[]' array
- Shell script: myscript
automates the address-lookup and module-installation steps for 'myexport.ko'
- lesson26.ppt (PowerPoint Slides)
- Demo program: segvtrap.cpp
shows how you could use a signal-handler to help you diagnose application bugs
- Developer tool: run.cpp
allows you to easily see the value of an application-program's 'exit-status'
- Demo program: printmac.cpp
for use when testing your 'dynamic patching' solution to Final Exam question 6
- Exam solution: maccall.c
performs the dynamic kernel patching that was asked for in Final Exam question 6
- Demo program: ShowEflags.java
shows how a Java program can call an external function written in C++
(in the source-file ShowEflags.cpp)
which also includes the use of some inline x86 assembly language!
- Demo program: 8139regs.c
creates a pseudo-file that shows most RealTek-8139 programming registers
- Demo remarks: author's commentary
regarding possible uses of the '8139regs.c' debugging tool (above)
Announcements
- Midterm Exam I: Wednesday, February 16.
- Project 1: Due: Friday, 18 March 2005, 9:00pm
- Midterm Exam II: Wednesday, March 9.
- Midterm Exam III: Monday, April 18.
- Project 2: Due: Wednesday, 11 May 2005, 9:00pm
- [Project 2 deadline extended till noon, Monday, May 23, by "popular demand"]
- FINAL EXAMINATION: Monday, 16 May 2005, 7:30pm
Last updated on 03 FEB 2016