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

From wiki.ucalgary.ca
< Courses‎ | Computer Science‎ | CPSC 457.F2013
Revision as of 15:42, 21 November 2013 by Mahshid.marbouti (talk | contribs) (Nov 14th: Time Measurement)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Tutorial topics that we will discuss each week are below.

T01  WF   MS160   8:00  Robin Gonzalez
T02  TR    TBD    8:00  Mahshid Marbouti
T03  TR    TBD   17:00  Mahshid Marbouti
T04  TR    TBD    11:00  Xiao Wei Liu
T05  MW   MS160  13:00  Robin Gonzalez
T06  MW    TBD    13:00  Ahmad Ahmadi Fatlaki

Tutorials begin on September 16, 2013

September 16: 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 17: 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

http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/IntroC2.pdf

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

http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Shell1.pdf

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

http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Shell2.pdf

Oct 7: LKM Intro

Notes

Helpful Links

October 14th: Downloading and Compiling the Kernel Source

Follow these directions from the kernel itself

http://lxr.cpsc.ucalgary.ca/lxr/#linux/README#L138

Example

(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/checksyscalls.sh
 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:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
(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
CREDITS		include/   MAINTAINERS	README		System.map
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	 mtools.conf.in  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    install.sh  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 [ https://www.dropbox.com/s/mulsuvyp9yzj2gt/System%20Call.pdf ]

Exercises: [ https://www.dropbox.com/s/ixdhfdv0usucqkz/BUILD%26ADDSYSTEMCALL.pdf ]

"Sample User Space Code" [ https://www.dropbox.com/s/8bqbd4808fiwhoh/hello.c ]

Helpful Links: [ http://arvindsraj.wordpress.com/2012/10/05/adding-hello-world-system-call-to-linux/]

http://www.cs.ucr.edu/~kishore/cs153_w09/syscall-assignment/how-to-add-system-call.txt

October 21st: Adding a System Call (continue)

Exercises http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Exercises/Reeducate.pdf

System call sample "http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/sys_reeducate.c"

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:

http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Exercises/Reeducate.pdf

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

http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Source_Code/sys_reeducate.c

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.

Exercise:

http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Exercises/Patching.pdf

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: https://www.dropbox.com/s/dwwiq7deqnaicjl/Timemeasurement%20Tutorial.pdf

Exercises for today: http://pages.cpsc.ucalgary.ca/~gonzalre/CPSC457/Exercises/Measuring_time.pdf

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: https://www.dropbox.com/s/n0ti5qlvhfadqyg/TimeStampCounter.pdf

HelpfulLinks:

http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-system-programming-manual-325384.pdf

https://mail-attachment.googleusercontent.com/attachment/u/0/?ui=2&ik=b85643f52e&view=att&th=1426ecaf26810f9f&attid=0.1&disp=inline&realattid=f_ho6ou6w31&safe=1&zw&saduie=AG9B_P-mSXSDWuvEGSzRk9Jvw7oW&sadet=1385048329151&sads=rOkn7xvVCbqAy-LBpyNECG0pVwQ&sadssc=1

http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/ia-32-ia-64-benchmark-code-execution-paper.pdf

http://software.intel.com/en-us/forums/topic/287418

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:

http://lxr.cpsc.ucalgary.ca/lxr/#linux+v2.6.32/Documentation/CodingStyle#L425 (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?

Warmup

Task

  • 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