Skip to content

Commit 1cf0919

Browse files
valighitadbaluta
authored andcommitted
documentation: labs: create SO2 lab1 from introduction and kernel_modules labs
Signed-off-by: Valentin Ghita <valx92@gmail.com>
1 parent fac865c commit 1cf0919

File tree

5 files changed

+288
-15
lines changed

5 files changed

+288
-15
lines changed

Documentation/teaching/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ tools/labs/docs/Dockerfile for dependencies):
4040
4141
cd tools/labs && make docs
4242
43+
.. toctree::
44+
45+
so2/index.rst
46+
4347
.. toctree::
4448
:caption: Lectures
4549

46-
lectures/so2.cs.pub.ro.rst
4750
lectures/intro.rst
4851
lectures/syscalls.rst
4952
lectures/interrupts.rst

Documentation/teaching/labs/introduction.rst

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Keywords
1717
* cscope, LXR
1818
* gdb, /proc/kcore, addr2line, dump\_stack
1919

20+
..
21+
_[SECTION-ABOUT-BEGIN]
22+
2023
About this laboratory
2124
=====================
2225

@@ -38,8 +41,14 @@ For best laboratory performance, we recommend that you read the related slides.
3841
To fully understand a laboratory, we recommend going through the lab support. For
3942
in-depth study, use the supporting documentation.
4043

41-
Documentation
42-
=============
44+
..
45+
_[SECTION-ABOUT-END]
46+
47+
..
48+
_[SECTION-REFERENCES-BEGIN]
49+
50+
References
51+
==========
4352

4453
- Linux
4554

@@ -55,6 +64,12 @@ Documentation
5564
- `mailing list <http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/pso>`__
5665
(`searching the mailing list <http://blog.gmane.org/gmane.education.region.romania.operating-systems-design>`__)
5766

67+
..
68+
_[SECTION-REFERENCES-END]
69+
70+
..
71+
_[SECTION-CODE-NAVIGATION-BEGIN]
72+
5873
Source code navigation
5974
======================
6075

@@ -248,8 +263,14 @@ a copy, because SourceWeb doesn't have, at this moment, the capability
248263
to regenerate the index for a single file and you will have to regenerate
249264
the complete index.
250265

251-
Debugging
252-
=========
266+
..
267+
_[SECTION-CODE-NAVIGATION-END]
268+
269+
..
270+
_[SECTION-DEBUGGING-BEGIN]
271+
272+
Kernel Debugging
273+
================
253274

254275
Debugging a kernel is a much more difficult process than the debugging
255276
of a program, because there is no support from the operating system.
@@ -402,6 +423,12 @@ execution paths, which makes this method difficult.
402423
In these situations, it is useful to get a stack trace, which can be
403424
simply done using the function :code:`dump_stack()`.
404425
426+
..
427+
_[SECTION-DEBUGGING-END]
428+
429+
..
430+
_[SECTION-DOCUMENTATION-BEGIN]
431+
405432
Documentation
406433
=============
407434
@@ -426,9 +453,15 @@ A few links related to the Linux kernel are shown bellow:
426453
The links are not comprehensive. Using `The Internet <http://www.google.com>`__ and
427454
`kernel source code <http://lxr.free-electrons.com/>`__ is essential.
428455
456+
..
457+
_[SECTION-DOCUMENTATION-END]
458+
429459
Exercises
430460
=========
431461
462+
..
463+
_[SECTION-EXERCISES-REMARKS-BEGIN]
464+
432465
Remarks
433466
-------
434467
@@ -455,8 +488,14 @@ Remarks
455488
.. important::
456489
Before solving an exercice, **carefully** read all its bullets.
457490
458-
1. Booting the virtual machine
459-
------------------------------
491+
..
492+
_[SECTION-EXERCISES-REMARKS-END]
493+
494+
..
495+
_[EXERCISE1-BEGIN]
496+
497+
Booting the virtual machine
498+
---------------------------
460499
461500
A summary of the virtual machine infrastructure:
462501
@@ -495,8 +534,14 @@ the :command:`QEMU_DISPLAY=sdl make boot`.
495534
The virtual machine will start with the permissions of the
496535
root account.
497536
498-
2. Adding and using a virtual disk
499-
----------------------------------
537+
..
538+
_[EXERCISE1-END]
539+
540+
..
541+
_[EXERCISE2-BEGIN]
542+
543+
Adding and using a virtual disk
544+
-------------------------------
500545
501546
.. note:: If you don't have the file :file:`mydisk.img`, you can download
502547
it from the address http://elf.cs.pub.ro/so2/res/laboratoare/mydisk.img.
@@ -579,8 +624,14 @@ With support for the :command:`btrfs` filesystem, now :command:`mount` will fini
579624
you to return to the initial setup in order to have an environment
580625
identical to the one used by vmchecker.
581626
582-
3. GDB and QEMU
583-
---------------
627+
..
628+
_[EXERCISE2-END]
629+
630+
..
631+
_[EXERCISE3-BEGIN]
632+
633+
GDB and QEMU
634+
------------
584635
585636
We can investigate and troubleshoot the QEMU virtual machine in real time.
586637
@@ -636,6 +687,12 @@ such as :command:`list` and :command:`backtrace` to trace the execution.
636687
.. hint:: At the :command:`gdb` prompt, you can press :command:`Enter`
637688
(without anything else) to rerun the last command.
638689
690+
..
691+
_[EXERCISE3-END]
692+
693+
..
694+
_[EXERCISE4-BEGIN]
695+
639696
4. GDB spelunking
640697
-----------------
641698
@@ -681,6 +738,13 @@ The :code:`jiffies` variable holds the number of ticks (clock beats) since the s
681738
682739
x/wx & jiffies
683740
741+
..
742+
_[EXERCISE4-END]
743+
744+
..
745+
_[EXERCISE5-BEGIN]
746+
747+
684748
5. Cscope spelunking
685749
--------------------
686750

Documentation/teaching/labs/kernel_modules.rst

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ Lab objectives
1010
* presenting how a module can be used with a kernel
1111
* simple kernel debugging methods
1212

13-
Overview
14-
========
13+
..
14+
_[SECTION-OVERVIEW-BEGIN]
15+
16+
Kernel Modules Overview
17+
=======================
1518

1619
A monolithic kernel, though faster than a microkernel, has the disadvantage of
1720
lack of modularity and extensibility. On modern monolithic kernels, this has
@@ -25,6 +28,12 @@ For the development of Linux device drivers, it is recommended to download the
2528
kernel sources, configure and compile them and then install the compiled version
2629
on the test /development tool machine.
2730

31+
..
32+
_[SECTION-OVERVIEW-END]
33+
34+
..
35+
_[SECTION-MODULE-EXAMPLE-BEGIN]
36+
2837
An example of a kernel module
2938
=============================
3039

@@ -72,6 +81,12 @@ by the logging daemon (syslog). To display kernel messages, you can use the
7281
Hi
7382
Bye
7483
84+
..
85+
_[SECTION-MODULE-EXAMPLE-END]
86+
87+
..
88+
_[SECTION-COMPILE-MODULES-BEGIN]
89+
7590
Compiling kernel modules
7691
========================
7792

@@ -173,6 +188,11 @@ follows:
173188
For more details, see the :file:`Documentation/kbuild/makefiles.txt` and
174189
:file:`Documentation/kbuild/modules.txt` files within the kernel sources.
175190

191+
..
192+
_[SECTION-COMPILE-MODULES-END]
193+
194+
..
195+
_[SECTION-LOAD-MODULES-BEGIN]
176196
177197
Loading/unloading a kernel module
178198
=================================
@@ -230,8 +250,14 @@ Information about modules loaded into the kernel can be found using the
230250
:command:`lsmod` command or by inspecting the :file:`/proc/modules`,
231251
:file:`/sys/module` directories.
232252
233-
Debugging
234-
=========
253+
..
254+
_[SECTION-LOAD-MODULES-END]
255+
256+
..
257+
_[SECTION-DEBUG-MODULES-BEGIN]
258+
259+
Kernel Module Debugging
260+
=======================
235261
236262
Troubleshooting a kernel module is much more complicated than debugging a
237263
regular program. First, a mistake in a kernel module can lead to blocking the
@@ -908,6 +934,9 @@ breakpoint to monitor the changes of the ``mVar`` variable.
908934
# return from KDB
909935
kdb> go
910936
937+
..
938+
_[SECTION-DEBUG-MODULES-END]
939+
911940
Exercises
912941
=========
913942
@@ -958,6 +987,9 @@ in the Linux kernel source code:
958987
For more info on using :command:`cscope`, read the
959988
:ref:`cscope section <cscope_intro>` in the previous lab.
960989
990+
..
991+
_[EXERCISE1-BEGIN]
992+
961993
1. Kernel module
962994
----------------
963995
@@ -999,6 +1031,13 @@ using `minicom -D serial.pts` and perform the following tasks:
9991031
a kernel module, you can specify only the module name
10001032
(without extension).
10011033
1034+
..
1035+
_[EXERCISE1-END]
1036+
1037+
..
1038+
_[EXERCISE2-BEGIN]
1039+
1040+
10021041
2. Printk
10031042
---------
10041043
@@ -1017,6 +1056,12 @@ Load/unload the module again.
10171056
The messages should not be printed to the virtual machine console,
10181057
but they should be visible when running ``dmesg``.
10191058
1059+
..
1060+
_[EXERCISE2-END]
1061+
1062+
..
1063+
_[EXERCISE3-BEGIN]
1064+
10201065
3. Error
10211066
--------
10221067
@@ -1029,6 +1074,12 @@ errors occurred? **Hint:** How does this module differ from the previous module?
10291074
Modify the module to solve the cause of those errors, then compile and test
10301075
the module.
10311076
1077+
..
1078+
_[EXERCISE3-END]
1079+
1080+
..
1081+
_[EXERCISE4-BEGIN]
1082+
10321083
4. Sub-modules
10331084
--------------
10341085
@@ -1043,6 +1094,12 @@ two C source files.
10431094
Compile, copy, boot the VM, load and unload the kernel module. Make sure messages
10441095
are properly displayed on the console.
10451096
1097+
..
1098+
_[EXERCISE4-END]
1099+
1100+
..
1101+
_[EXERCISE5-BEGIN]
1102+
10461103
5. Kernel oops
10471104
--------------
10481105
@@ -1073,6 +1130,12 @@ kernel since the oops; Until the release of those references (which is
10731130
almost impossible in the case of an oops), the module can not be
10741131
unloaded.
10751132
1133+
..
1134+
_[EXERCISE5-END]
1135+
1136+
..
1137+
_[EXERCISE6-BEGIN]
1138+
10761139
6. Module parameters
10771140
--------------------
10781141
@@ -1090,6 +1153,12 @@ message shown is ``Early bird gets tired``.
10901153
10911154
.. _proc-info:
10921155
1156+
..
1157+
_[EXERCISE6-END]
1158+
1159+
..
1160+
_[EXERCISE7-BEGIN]
1161+
10931162
7. Proc info
10941163
------------
10951164
@@ -1126,6 +1195,12 @@ from the executable :file:`/sbin/insmod` when the module is loaded and
11261195
when the module is unloaded a process is created from the executable
11271196
:file:`/sbin/rmmod`.
11281197
1198+
..
1199+
_[EXERCISE7-END]
1200+
1201+
..
1202+
_[EXTRA-EXERCISE-BEGIN]
1203+
11291204
Extra Exercises
11301205
===============
11311206
@@ -1268,3 +1343,6 @@ Without unloading the module, deactivate :c:func:`pr_debug` calls.
12681343
12691344
.. hint::
12701345
You can delete the set flags. Unload the kernel module.
1346+
1347+
..
1348+
_[EXTRA-EXERCISE-END]

Documentation/teaching/so2/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
===================
2+
Operating Systems 2
3+
===================
4+
5+
6+
.. toctree::
7+
:caption: Lectures
8+
:maxdepth: 1
9+
10+
../lectures/so2.cs.pub.ro.rst
11+
12+
.. toctree::
13+
:caption: Labs
14+
:maxdepth: 1
15+
16+
lab1-intro.rst

0 commit comments

Comments
 (0)