CS 326: Operating Systems (Fall 2004)
Lecture: Monday-Wednesday 3:30pm-5:15pm (235 Harney Science Center)
Laboratory: Friday 11:35am-1:20pm (535 Harney Science Center)
Instructor:
Allan Cruse
Email:
cruse@usfca.edu
Phone: (415) 422-6562
Office: 212 Harney Science Center
Office Hours: (see my homepage)
Teaching Assistant:
Anna Tikhonova
Consulting hours: 5:30-6:30 Tuesdays, 3:00-4:00 Fridays (5th Floor CS Lab)
Synopsis:
This course acquaints computer science undergraduates with general design
principles, internal algorithms and data structures, and key
application-interface
features of modern multitasking operating systems
(such as Windows or UNIX).
It will give special emphasis to the Linux
"Open Source" operating system, and
will employ the GNU assembler,
C compiler, and program development tools.
The course will consist of lectures, labs, readings, discussions,
demonstrations,
consultations, independent design projects and scheduled
exams, in addition to
in-class programming exercises and experiments.
Students are presumed to have prior experience doing computer programming
in at least one high-level language (such as C/C++/Java), and to be
familiar with
basic operating system commands (e.g., as covered in
CS 110 and 112). Formal
prerequisites include CS 210 (Assembly
Language and Systems Programming)
and CS 245 (Data Structures and
Algorithms).
Learning Outcomes:
- You will gain an overview of how a computer system's components interact
- You will become familiar with standard OS algorithms and design issues
- You will acquire experience in writing and debugging UNIX system software
- You will understand what would be entailed in adding new system features
- You will be able to diagnose malfunctions, and to forestall bottlenecks
- You will lay the conceptual ground for understanding later CS courses
Class lectures will be held in the
Michael D. Kudlick computer classroom
(Room 235, Harney Science Center) which affords convenient opportunities
for combining formal instruction with "hands-on" programming exercises.
This facility, a gift of USF alumnus
Alfred S. Chuang ('82), opened in Fall 2002.
Textbook(s):
Also recommended -- if available (but not required):
Readings
- Sep 01: Gary Nutt, Overview of Linux
- Sep 08: Stallings, Computer System Overview
- Sep 16: Stallings, Operating System Overview
- Sep 22: Stallings, Process Description and Control
- Sep 29: Stallings, Threads, SMP, and Microkernels
- Oct 06: Stallings, Concurrency: Mutual Exclusion and Synchronization
- Oct 13: Stallings, Concurrency: Deadlock and Starvation
- Oct 20: Stallings, Memory Management
- Oct 27: Stallings, Virtual Memory
- Nov 03: Stallings, Uniprocessor Scheduling
- Nov 10: Stallings, Multiprocessor and Real-Time Scheduling
- Nov 17: Stallings, I/O Management and Disk Scheduling
- Nov 24: Stallings, File Management
- Dec 01: Stallings, Networking
- Dec 08: Stallings, Security
Resources
- Classic C language reference by Brian Kernighan and Dennis Ritchie,
The C Programming Language (2nd Edition), Prentice-Hall (1988)
- Classic C function reference by Donald Lewine,
POSIX Programmer's Guide: Writing Portable UNIX Programs
O'Reilly and Associates, Inc (1991)
- Technical introduction by Friedhelm Schmidt, The SCSI Bus and IDE Interface (2nd Edition), Addison-Wesley (1997)
- Website for current ATA Disk-Drive Interface
Draft ANSI Standards Documentation by INCITS Technical Committee T13
- Online book about kernel modules: Rubini and Corbett,
Linux Device Drivers (2nd Edition), O'Reilly (2001)
- Classic textbook: W. Richard Stevens,
Advanced Programming in the UNIX Environment, Addison-Wesley (1992)
- Official Intel Pentium
IA-32 Programmer Reference Manuals online
-
Unix semaphore example-code helpful inline comments are included
- Official documentation for the Linux Executable and Linkable Format (ELF)
files:
elf.pdf
- Online tutorial on writing
Linker Scripts
for the GNU linker 'ld' (FSF and RedHat, Inc.)
- Online article:
Design and Implementation of the Second Extended Filesystem
- Official RealTek programming references:
RTL8139_ProgrammersGuide and
RTL8139D_DataSheet
Handouts
- 0203-326-01: Course syllabus (PDF)
- lesson1.ppt (PowerPoint Slides)
- Demo program: idnumber.cpp
an application that illustrates direct peripheral-device programming
- System utility: iopl3.cpp (by Alex Fedosov)
lets application-programs execute x86 in/out instructions
- lesson2.ppt (PowerPoint Slides)
- Demo program: mywrite.c
helps clarify the role of header-files (by showing how we could omit them)
- Demo program: filedemo.s
showing how an application can make direct system-calls to the Linux kernel
- lesson3.ppt (PowerPoint Slides)
- Makefile needed for compiling kernel modules
- Exercise solution: jiffies.c
illustrating creation of a simple, but useful pseudo-file
- Exercise solution: showjifs.cpp
uses the pseudo-file to help measure how fast 'jiffies' increments
- Demo program: myexec.s
shows how to directly invoke the Linux 'sys_execve' kernel service
- Demo program: showargs.cpp
used for partial testing of the 'myexec.s' demo-program
- Demo program: showhost.cpp
used for partial testing of the 'myexec.s' demo-program
- Demo program: myshell.cpp
(the "bare bones" skeleton for a shell application-program)
<-- revised on 9/22/04
- lesson4.ppt (PowerPoint Slides)
- Demo program: nocache.c
used for temporarily disabling the processor's cache mechanism
- Demo program: cr0.cpp
for confirming that the CPU cache was disabled, or was reenabled
- Demo program: sieve.cpp
for use in studying effects of the processor's cache mechanism
- Demo program: fsieve.cpp
for studying effects of the operating system's cache mechanism
- lesson5.ppt (PowerPoint Slides)
- Demo program: tasklist.c
creates a pseudo-file named '/proc/tasklist' showing current tasks
- Demo program: sleep.c
creates a pseudo-file that shows each task's state and sleep_time
- Demo program: mysignal.cpp
shows how you can use 'signal()' to install your own signal-handler
- Demo program: killdemo.cpp
shows how you can use 'kill()' to send another process a signal
- Demo program: myitimer.cpp
shows how you can use 'setitimer()' to generate 'SIGALRM' signals
- lesson6.ppt (PowerPoint Slides)
- Demo program: dumptcb.cpp
a program which displays its own 'task_struct' in hexadecimal format
- Demo program: tcb.c
the module that is needed when executing our 'dumptcb' application
- Demo program: realtimers.c
creates a pseudo-file showing which tasks have an active real_timer
- Demo program: trytimer.cpp
shows effects of 'setitimer()' on fields within the 'task_struct'
- Demo program: timerinfo.c
the module that is needed when executing our 'trytimer' demo
- lesson7.ppt (PowerPoint Slides)
- Demo program: mm.c
creates a pseudo-file showing information from a task's 'mm_struct'
- Demo program: mmfork.cpp
uses our 'mm.o' module to show 'mm_struct' info for a parent and child
- Demo program: vma.c
creates a pseudo-file showing a task's currently mapped memory regions
- Demo program: getinfo.c
shows changes to the 'get_info()' interface (needed for Kernel Project #4)
- lesson8.ppt (PowerPoint Slides)
- Demo program: tryclone.cpp
uses 'clone()' to create separate threads in same or copied address-space
- Demo program: switcher.cpp
shows simplified scheduling of four 'threads' within a single 'process'
- lesson9.ppt (PowerPoint Slides)
- Demo program: myexport.c
enables us to do 'dynamic patching' of a hidden kernel data-structure
- Shell script: myscript
automates the complex steps needed to install our 'myexport' module
- Demo program: newcall.c
dynamically implements a new 'method' for the obsolete system-call 17
- Demo program: invoke17.cpp
an application to use for testing the 'new' effect of system-call 17
- Demo program: 2signals.cpp
demonstrates use of the fork(), signal(), and setitimer() functions
- Demo program: showvmap.cpp
displays a 'map' of the 4GB virtual memory space (in 4MB chunks)
- Demo program: vmap.c
this is the kernel module needed when executing our 'showvmap' demo
- lesson10.ppt (PowerPoint Slides)
- Demo program: concur1.cpp
showing why thread-synchronization is needed for multiprogramming
- Demo program: concur2.cpp
revises 'concur1.cpp' to incorporate the use of 'mutual exclusion'
- Demo program: yielding.cpp
demonstrates the 'nanosleep()' system-call in Linux multiprogramming
- Demo program: concur3.cpp
revises 'concur2.cpp' using 'nanosleep()' to reduce 'busy-waiting'
- Demo program: tryshm.cpp
uses standard UNIX functions which let two tasks exhange some data
- lesson11.ppt (PowerPoint Slides)
- Demo program: racedemo.cpp
illustrates unsynchronized access to a common resource by two tasks
- Demo program: racecure.cpp
shows how 'signals' could efficiently synchronize two competing tasks
- lesson12.ppt (PowerPoint Slides)
- Demo program: lottery.cpp
implements a lottery-number 'server' that writes to shared memory
- Demo program: gambler.cpp
implements a lottery-player 'client' that reads from shared memory
- Header file: myshmsem.h
for the constants and types used by our lottery-and-gambler demos
- Exercise prototpe: children.cpp
forks and execs several children with different random number-strings
- Demo program: showarg1.cpp
this is the demo-program used with our 'children.cpp' example above
- Demo program: pgfaults.c
installs a kernel function which provides statistics on page-faults
- lesson13.ppt (PowerPoint Slides)
- Demo program: useasm.cpp
illustrates use of the 'asm' construct for inline assembly language
- lesson14.ppt (PowerPoint Slides)
- Demo program: courseid.cpp
uses the 'asm' construct and avoids any use of standard C functions
- Special Utility Program: elfinfo.cpp
shows the locations and sizes of the sections in an ELF file
- Special Linker Script: ldscript
for compiling our 'courseid.cpp' demo as a binary-format executable
- Demo program: launch.cpp
illustrates use of the 'mmap()' function (and also executes 'courseid.b')
- lesson15.ppt (PowerPoint Slides)
- Demo program: stash.c
demonstrates the use of a 'wait queue' by a simple device-driver module
- lesson16.ppt (PowerPoint Slides)
- Kernel module: cr3.c
creates a pseudo-file showing the current task's page-directory address
- Device driver: dram.c
provides read-only access to the machine's installed physical memory
- Demo program: showpdir.cpp
shows the current task's page-directory (using the two modules above)
- System utility: fileview.cpp
shows the contents of a file or device in hexadecimal and ascii format
<-- bug fixed 08/27/2005
- lesson17.ppt (PowerPoint Slides)
- In-progress demo: channels.c
and channels.h
(skeleton-code for a custom kernel mechanism) <-- revised 11/10/2004
- Demo program: trychannel.cpp
(it can be used during testing of our 'channels' kernel-object mechanism)
- Demo program: notifier.c creates a pseudo-file
for viewing the 'notifier' fields in all active task_structs
- Demo program: trynotif.c
(this installs a notification-function in each stopped task's 'notifier' field)
- Demo programs: loadonly.cpp
and pidhello.cpp
(for experimenting with our 'trynotif.o' module)
- Demo program: newsched.c
shows how 'dynamic patching' could activate an alternative task-scheduler
<-- revised 11/13/2004
- lesson18.ppt (PowerPoint Slides)
- System utility: newinfo.cpp
creates the 'boilerplate' source-code for a 'get_info()' /proc module
- Demo program: memused.c
lets an application program see the amount of virtual memory it is using
- Demo program: freydemo.c
illustrates use of Linux kernel threads (adapting a demo by Martin Frey)
- Demo program: vram.c
implements a device-driver's 'read()', 'write()', and 'llseek()' methods
- Demo program: vramdraw.cpp
this program exercises some functions of the 'vram.c' device-driver
<-- revised 12/13/2004
- lesson19.ppt (PowerPoint Slides)
- Demo program: ioctl.c
illustrates memory-mapping of SiS 315 graphics engine's i/o ports
- Demo program: tryioctl.cpp
invokes 'ioctl()' system-calls to hide or show the graphics cursor
- lesson20.ppt (PowerPoint Slides)
- Demo program: clockalg.cpp
shows a simple simulation comparing some page-replacement policies
- lesson21.ppt (PowerPoint Slides)
- Demo program: kthreads.c
creates a pseudo-file showing the name and PID of each kernel thread
- lesson22.ppt (PowerPoint Slides)
- Demo program: myfiles.c
creates a pseudo-file showing the name of each file opened by a process
- Lab tools: mkfiles.cpp
and mk1440kb.cpp
for use during study of floppy diskette storage capabilities
- lesson23.ppt (PowerPoint Slides)
- Demo program: watch235.c
creates a pseudo-file that lets applications examine network packets
- Demo program: trywatch.cpp
an application that demonstrates use of our 'watch235.c' driver module
- Encrypted textfile: encrypted.txt
for your use with the exercise in question V on the Final Exam
- Demo program: encrypt.cpp
this is the application used to produce the encrypted textfile above
- Demo program: matmult.cpp
illustrates some key principles of 'thread safe' multiprogramming
Announcements
- No lab meetings during registration-week (August 23-27)
- Noon, Friday, Sep 17: submit Kernel Projects Lab #1
- Noon, Friday, Sep 24: submit Kernel Projects Lab #2
- Noon, Friday, Oct 01: submit Kernel Projects Lab #3
- Midterm Exam 1: Monday, 4 October 2004
- Noon, Friday, Oct 08: submit Kernel Projects Lab #4
- Noon, Friday, Oct 15: submit Kernel Projects Lab #5
- Noon, Friday, Oct 22: submit Kernel Projects Lab #6
- Noon, Friday, Oct 29: submit Kernel Projects Lab #7
- Noon, Friday, Nov 05: submit Kernel Projects Lab #8
(deadline extended to Nov 12)
-- Lab meeting today is rescheduled for 3:30-5:15pm in HRN-235
-- for special Linux 2.6 kernel config/compile/install demonstration
- Noon, Friday, Nov 12: submit Kernel Projects Lab #9
(deadline extended to Nov 26)
- Midterm Exam 2: Wednesday, 17 November 2004
- Noon, Friday, Dec 03: submit Kernel Projects Lab #10
- FINAL EXAMINATION: Tuesday, 14 December 2004, NOON
Last updated on 08/27/2005