Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 10 homework #115

Open
wants to merge 5 commits into
base: Vadym.Mishchuk
Choose a base branch
from
Open
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion kthread_example/kthread_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
#include <linux/time.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use only required include headers

#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/spinlock.h>

#define N_THR 4

static struct task_struct *threads[N_THR];

DEFINE_SPINLOCK(critical_section);

static int thread_fn(void *ptr)
{

while (!kthread_should_stop()) {
pr_info("Kthread example: in thread %d\n", (int)ptr);
msleep_interruptible(1000);
spin_lock(&critical_section);
msleep_interruptible(200);
spin_unlock(&critical_section);
msleep_interruptible(800);
}

return 0;
Expand Down Expand Up @@ -47,6 +53,7 @@ void thread_cleanup(void)

if (!ret)
pr_info("Kthread example: thread %d stopped\n", i);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insignificant changes

}
}
}
Expand Down