Some of these programming assignments are described in the course book.
In the 9th Edition (the paper version), kernel modules are described in "Programming Projects" in chapter 2 (pages 94-98) and in project 2 in "Programming Projects" in chapter 3 (pages 156-158).
In the 10th Edition (the electronic version), kernel modules are described in "Programming Projects" in chapter 2 (there are no page numbers) and in project 2 and 3 in "Programming Projects" in chapter 3.
The 10th Edition of the book, and the accompanying virtual machine, uses Linux kernel version 4.4. (The machines in T002 have this kernel.) The 9th Edition of the book, and its virtual machine, uses an older kernel version, 3.16.
Here is a graph showing its performance on a computer with an Intel Core i7-6850K CPU from 2016. It has 6 cores and hyperthreading. As you can see, performance increases linearly with the number of threads up to 12 threads, but with 13 or more threads the increase stops. Question: Why is that?
(Click the graph see a larger version.)
Here is another graph, showing the program's performance on the university's ThinLinc server, which runs on an Intel Xeon Gold 6136 CPU from 2017. According to its specifications, this processor type has 12 cores and hyperthreading. Question: Can you explain these results?
(Click the graph see a larger version.)
Run the same thread performance test program on your computer. Question: What results do you get? Explain your results!
You can start without locking, and see if you get incorrect results.
Start without locking, and see if you get incorrect results.
See also the "MONSTER-WORLD-README" file.
Possibly useful command: "gcc -Wall -Wextra -std=c11 -O3 multi-threaded-monster-world.c -lpthread -o multi-threaded-monster-world". With the following Makefile you can just type "make multi-threaded-monster-world":
CC = gcc CFLAGS += -Wall -Wextra -std=c11 -O3 LDLIBS += -lpthread
Question:
Is the multi-threaded version faster?
Why, or why not?
What about the same multi-threaded version but with no locks?
Questions: Which results do you get? What are the times for the single-threaded version, the multi-threaded version without locking, and the multi-threaded version with locking? Are the multi-threaded versions faster? Explain the results!
If you are running this in a modern Linux (kernel version
4.4.0-20 or later) on a computer where Secure Boot is enabled, it will
fail with the error message "Operation not permitted", and in the
kernel messages (dmesg) it will print "insmod: Loading of unsigned
module is restricted; see man kernel_lockdown.7". This is beacause
kernel modules have to be signed. Either turn off Secure Boot (not
recommended), run in a virtual machine without Secure Boot, or sign
your module (after each recompilation). Here is a Stack Overflow
answer that explains how to sign your kernel modues:
(They are signing a module called vboxdrv, so you need to replace that with the name of your module.) |
There are macros to loop through processes, and they might be different between kernel 3 and 4.
An update: Note that in later kernels, the macro for_each_process has been moved to the #include file <linux/sched/signal.h>
Run the threaded program from task 1 or task 2 to verify that your module works.