Courses/Computer Science/CPSC 457.F2014/Tutorial Schedule

Jump to: navigation, search

Tutorial topics that we will discuss each week are below.

T01  WF   MS160   8:00  James, C.
T02  TR    MS160    8:00  Afshar, A.
T03  TR    MS119   17:00  Gonzalez, R.
T04  TR    MS119    11:00  Afshar, A.
T05  MW   MS160  13:00  Gonzalez, R.

Tutorials begin on September 17, 2014 (All dates on this website are tentative and subject to changes)

September 17: Introduction to VirtualBox

Give the students an understanding of how virtualization works, setting up hardware specifications for a VM, and how to boot a VM.

September 18: Introduction to SVNs

Brief tutorial on using SVN as a revision control for software, file management, or documentation.

Helpful Links

September 23: Introduction to C (Part 1)

Introduction to the C syntax and compilation of C programs. We wrote a small Hello World program and compiled it, then worked with calling different functions to print the Hello World message and to get used to the C syntax. We also briefly introduced makefiles and the advantages of using them when developing our code.

September 25: Introduction to C (Part 2)

We continued our C introduction by studying other components that are not found in other programming languages. In this class we studied structures, unions, and arrays. We also studied pointers and how we can pass variables by value and by reference. We also worked with Makefiles and compiling several files at once.

Exercise for this tutorial

September 30: Writing a Linux Shell (Part 1)

We studied how to implement the parsing and prompting of a linux shell using the C programming language.

Exercise for this tutorial

October 2: Writing a Linux Shell (Part 2)

Continuation of previous tutorial. We studied how to execute commands generated by an user in the shell programmed in the previous tutorial. For this, we use the system calls fork() and execve().

Exercise for this tutorial

Oct 7: LKM Intro


Helpful Links

October 14th: Downloading and Compiling the Kernel Source

Follow these directions from the kernel itself


(eye@mordor ~)$ cd 457/kernel/
(eye@mordor kernel)$ ls
kernel-2.6.32-358.18.1.el6.src.rpm  linux-2.6.32/
(eye@mordor kernel)$ cd linux-2.6.32/
(eye@mordor linux-2.6.32)$ make oldconfig
...answer a few dozen questions, mostly with "no"...
(eye@mordor linux-2.6.32)$ make
 CHK     include/linux/version.h
 CHK     include/linux/utsrelease.h
 SYMLINK include/asm -> include/asm-x86
 CALL    scripts/
 CHK     include/linux/compile.h
 CHK     include/linux/version.h
...1.5 hours and 79% of my battery later...
make[2]: `scripts/unifdef' is up to date.
Kernel: arch/x86/boot/bzImage is ready  (#1)
  Building modules, stage 2.
  MODPOST 1785 modules
WARNING: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
(eye@mordor linux-2.6.32)$ 

So what's new here?

(eye@mordor linux-2.6.32)$ ls
arch/		drivers/   Kbuild	modules.order	scripts/    virt/
block/		firmware/  kernel/	Module.symvers	security/   vmlinux*
COPYING		fs/	   lib/		net/		sound/	    vmlinux.o
crypto/		init/	   Makefile	REPORTING-BUGS	tools/
Documentation/	ipc/	   mm/		samples/	usr/

Oh, this vmlinux file looks like an interesting excutable.

(eye@mordor linux-2.6.32)$ file vmlinux
vmlinux: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped

It's an ELF???!!??!? Yep.

(eye@mordor linux-2.6.32)$ ls arch/x86/boot/
a20.c	     copy.S	 mca.c		 regs.o        video.c
a20.o	     cpu.c	 mca.o		 setup.bin*    video.h
apm.c	     cpucheck.c  memory.c	 setup.elf*    video-mode.c
apm.o	     cpucheck.o  memory.o	 setup.ld      video-mode.o
bioscall.o   cpu.o	 mkcpustr*	 string.c      video.o
bioscall.S   cpustr.h	 mkcpustr.c	 string.o      video-vesa.c
bitops.h     edd.c  tools/        video-vesa.o
boot.h	     edd.o	 pm.c		 tty.c	       video-vga.c
bzImage      header.o	 pmjump.o	 tty.o	       video-vga.o
cmdline.c    header.S	 pmjump.S	 version.c     vmlinux.bin*
cmdline.o  pm.o		 version.o     voffset.h
code16gcc.h  main.c	 printf.c	 vesa.h        zoffset.h
compressed/  main.o	 printf.o	 video-bios.c
copy.o	     Makefile	 regs.c		 video-bios.o
(eye@mordor linux-2.6.32)$ file arch/x86/boot/bzImage 
arch/x86/boot/bzImage: Linux kernel x86 boot executable bzImage, version 2.6.32 (eye@mordor) #1 SMP Wed , RO-rootFS, root_dev 0x803, swap_dev 0x3, Normal VGA
(eye@mordor linux-2.6.32)$ 

Now I can go on to 'sudo make modules_install install', which will create the appropriate entry in /etc/grub.conf for me, and then I can boot into my "new" kernel.

October 16th: Adding a System Call

In this tutorial, we are learning how to add a simple system call to our new Kernel. A system call is a way to allow users, use low level system functionalists like working with hardware. The following exercises are based on kernel version 2.6.32; it will help you how download, compile, configure and install the kernel and how to add a simple system call to our new kernel.

Slide [ ]

Exercises: [ ]

"Sample User Space Code" [ ]

Helpful Links: []

October 21st: Adding a System Call (continue)


System call sample ""

October 23rd: Kernel Data Structures

In this tutorial we work with the task_struct of a PID using the implementation of the system call "reeducate" for the Assignment#2.

Procedure for adding our system call:

Source Code for part of the implementation of reeducate(2):

October 28th: Patch / Diff

In this tutorial, we go through how to patch the kernel source code. After downloading a fresh copy of our kernel version, we used the diff command to get a patch with our modifications. We then applied the patch to the fresh copy of the kernel to update it according to our customizations.


Oct 30th Open Work Period

This tutorial is going to be dedicated on solving any doubts on assignments/exercises/concepts.

Nov 4th: Open Work Period

This tutorial is going to be dedicated on solving any doubts on assignments/exercises/concepts.

Nov 6th: Open Work Period

This tutorial is going to be dedicated on solving any doubts on assignments/exercises/concepts.

Nov 11th: Time Measurement

This tutorial is about measuring how long any part of your program may take. We introduce two system calls for this purpose: Time and Gettimeofday.

Notes for today:

Exercises for today:

Nov 14th: Time Measurement

In this tutorial we got familiar with rdtsc instruction in order to measure the time in a more precise mod.

Notes for this tutorial:


Nov 19th: Work Period

Nov 25th: Source Code Comments

In this tutorial, we will examine the value of Linux kernel comments and get some practical experience commenting the kernel source itself.

First, read "Chapter 8: Commenting" in the Linux Kernel Coding Style document: (through line 462). Note that this "chapter" is 37 lines long.

Next, spend 10 minutes grepping through the source code for interesting turns of phrase or salty language. You might want to search for keywords like: XXX, TODO, TOFIX or FIXME. You may want to look for words like "impossible, incorrect, not right, broken, silly" or similar terms.

Now, glance over the comments in these files:

Do there seem to be enough comments to understand what these pieces of code do?



  • Pick an arbitrary .c, .h, or .S file in the Linux kernel source code. Comment it.
  • Using the COMTOR model, rate the quality of comments in a kernel source file of your choosing.
  • Commit your work to your svn repository. You'll receive 1 point of extra credit for each function you comment or file you rate, up to maximum of 15.

Nov 27th: Open Work Period

Dec 2nd: Open Work Period

Dec 4th: Open Work Period