Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/teaching/labs/filesystems_part2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ In the minix case, the function is ``minix_lookup``.
This function is called indirectly when information about the inode associated with an entry in a directory is needed.
Such a function performs the following operations:

#. Searces in the directory indicated by ``dir`` the entry having the name ``dentry->d_name.name``.
#. Searches in the directory indicated by ``dir`` the entry having the name ``dentry->d_name.name``.
#. If the entry is found, it will return ``NULL`` and associate the inode with the name using the :c:func:`d_add` function.
#. Otherwise, returns ``ERR_PTR``.

Expand Down
144 changes: 144 additions & 0 deletions Documentation/teaching/so2/assign-collaboration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
=============
Collaboration
=============

Collaboration is essential in open source world and we encourage you
to pick a team partner to work on selected assignments.

Here is a simple guide to get you started:

1. Use Github / Gitlab
----------------------

Best way to share your work inside the team is to use a version control system (VCS)
in order to track each change. Mind that you must make your repo private and only allow
read/write access rights to team members.

2. Start with a skeleton for the assignment
-------------------------------------------

Add `init`/`exit` functions, driver operations and global structures that you driver might need.

.. code-block:: c

// SPDX-License-Identifier: GPL-2.0
/*
* uart16550.c - UART16550 driver
*
* Author: John Doe <[email protected]>
* Author: Ionut Popescu <[email protected]>
*/
struct uart16550_dev {
struct cdev cdev;
/*TODO */
};

static struct uart16550_dev devs[MAX_NUMBER_DEVICES];

static int uart16550_open(struct inode *inode, struct file *file)
{
/*TODO */
return 0;
}

static int uart16550_release(struct inode *inode, struct file *file)
{
/*TODO */
return 0;
}

static ssize_t uart16550_read(struct file *file, char __user *user_buffer,
size_t size, loff_t *offset)
{
/*TODO */
}

static ssize_t uart16550_write(struct file *file,
const char __user *user_buffer,
size_t size, loff_t *offset)
{
/*TODO */
}

static long
uart16550_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
/*TODO */
return 0;
}

static const struct file_operations uart16550_fops = {
.owner = THIS_MODULE,
.open = uart16550_open,
.release = uart16550_release,
.read = uart16550_read,
.write = uart16550_write,
.unlocked_ioctl = uart16550_ioctl
};

static int __init uart16550_init(void)
{
/* TODO: */
}

static void __exit uart16550_exit(void)
{
/* TODO: */
}

module_init(uart16550_init);
module_exit(uart16550_exit);

MODULE_DESCRIPTION("UART16550 Driver");
MODULE_AUTHOR("John Doe <[email protected]");
MODULE_AUTHOR("Ionut Popescu <[email protected]");

3. Add a commit for each individual change
------------------------------------------

First commit must always be the skeleton file. And the rest of the code should be on top of skeleton file.
Please write a good commit mesage. Explain briefly what the commit does and *why* it is necessary.

Follow the seven rules of writing a good commit message: https://cbea.ms/git-commit/#seven-rules

.. code-block:: console

Commit 3c92a02cc52700d2cd7c50a20297eef8553c207a (HEAD -> tema2)
Author: John Doe <[email protected]>
Date: Mon Apr 4 11:54:39 2022 +0300

uart16550: Add initial skeleton for ssignment #2

This adds simple skeleton file for uart16550 assignment. Notice
module init/exit callbacks and file_operations dummy implementation
for open/release/read/write/ioctl.

Signed-off-by: John Doe <[email protected]>

4. Split the work inside the team
---------------------------------

Add `TODOs` with each team member tasks. Try to split the work evenly.

Before starting to code, make a plan. On top of your skeleton file, add TODOs with each member tasks. Agree on global
structures and the overlall driver design. Then start coding.

5. Do reviews
-------------

Create Pull Requests with your commits and go through review rounds with your team members. You can follow `How to create a PR` `video <https://www.youtube.com/watch?v=YvoHJJWvn98>`_.

6. Merge the work
-----------------

The final work is the result of merging all the pull requests. Following the commit messages
one should clearly understand the progress of the code and how the work was managed inside the team.

.. code-block:: console

f5118b873294 uart16550: Add uart16550_interrupt implementation
2115503fc3e3 uart16550: Add uart16550_ioctl implementation
b31a257fd8b8 uart16550: Add uart16550_write implementation
ac1af6d88a25 uart16550: Add uart16550_read implementation
9f680e8136bf uart16550: Add uart16550_open/release implementation
3c92a02cc527 uart16550: Add skeleton for SO2 assignment #2
1 change: 1 addition & 0 deletions Documentation/teaching/so2/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Operating Systems 2
:caption: Assignments
:maxdepth: 1

assign-collaboration.rst
assign0-kernel-api.rst
assign1-kprobe-based-tracer.rst
assign2-driver-uart.rst
Expand Down
5 changes: 5 additions & 0 deletions tools/labs/skels/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# autogenerated, do not edit
ccflags-y += -Wno-unused-function -Wno-unused-label -Wno-unused-variable
obj-m += ./deferred_work/1-2-timer/
obj-m += ./deferred_work/3-4-5-deferred/kernel/
obj-m += ./deferred_work/6-kthread/
3 changes: 3 additions & 0 deletions tools/labs/skels/deferred_work/1-2-timer/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ccflags-y = -Wno-unused-function -Wno-unused-label -Wno-unused-variable

obj-m = timer.o
54 changes: 54 additions & 0 deletions tools/labs/skels/deferred_work/1-2-timer/timer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Deferred Work
*
* Exercise #1, #2: simple timer
*/

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>

MODULE_DESCRIPTION("Simple kernel timer");
MODULE_AUTHOR("SO2");
MODULE_LICENSE("GPL");

#define TIMER_TIMEOUT 1

static struct timer_list timer;

static void timer_handler(struct timer_list *tl)
{
/* TODO 1: print a message */
static size_t nseconds;

nseconds += TIMER_TIMEOUT;
pr_info("[timer_handler] nseconds = %d\n", nseconds);

/* TODO 2: rechedule timer */
mod_timer(tl, jiffies + TIMER_TIMEOUT * HZ);
}

static int __init timer_init(void)
{
pr_info("[timer_init] Init module\n");

/* TODO 1: initialize timer */
timer_setup(&timer, timer_handler, 0);

/* TODO 1: schedule timer for the first time */
mod_timer(&timer, jiffies + TIMER_TIMEOUT * HZ);

return 0;
}

static void __exit timer_exit(void)
{
pr_info("[timer_exit] Exit module\n");

/* TODO 1: cleanup; make sure the timer is not running after we exit */
del_timer_sync(&timer);
}

module_init(timer_init);
module_exit(timer_exit);
35 changes: 35 additions & 0 deletions tools/labs/skels/deferred_work/3-4-5-deferred/include/deferred.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SO2 - Lab 6 - Deferred Work
*
* Exercises #3, #4, #5: deferred work
*
* Header file.
*/

#ifndef __DEFERRED_H__
#define __DEFERRED_H__

#include <asm/ioctl.h>

#define MY_IOCTL_TIMER_SET _IOW('k', 1, unsigned long)
#define MY_IOCTL_TIMER_CANCEL _IO ('k', 2)
#define MY_IOCTL_TIMER_ALLOC _IOW('k', 3, unsigned long)
#define MY_IOCTL_TIMER_MON _IO ('k', 4)

/* converts ioctl command code to message */
inline static char *ioctl_command_to_string(int cmd)
{
switch(cmd) {
case MY_IOCTL_TIMER_SET:
return "Set timer";
case MY_IOCTL_TIMER_CANCEL:
return "Cancel timer";
case MY_IOCTL_TIMER_ALLOC:
return "Allocate memory";
case MY_IOCTL_TIMER_MON:
return "Monitor pid";
}
return "Unknown command";
}

#endif /* __DEFERRED_H__ */
3 changes: 3 additions & 0 deletions tools/labs/skels/deferred_work/3-4-5-deferred/kernel/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ccflags-y = -Wno-unused-function -Wno-unused-label -Wno-unused-variable

obj-m = deferred.o
Loading