]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
rcu thread
authorseantywork <seantywork@gmail.com>
Wed, 17 Sep 2025 23:49:26 +0000 (23:49 +0000)
committerseantywork <seantywork@gmail.com>
Wed, 17 Sep 2025 23:49:26 +0000 (23:49 +0000)
krcu-deadly/2509-17.xyz.md [deleted file]
krcu-deadly/README.md [new file with mode: 0644]
krcu-deadly/rcudeadly.c

diff --git a/krcu-deadly/2509-17.xyz.md b/krcu-deadly/2509-17.xyz.md
deleted file mode 100644 (file)
index 4287ca8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#
\ No newline at end of file
diff --git a/krcu-deadly/README.md b/krcu-deadly/README.md
new file mode 100644 (file)
index 0000000..136000e
--- /dev/null
@@ -0,0 +1,5 @@
+# kernel-rcu-deadly
+
+- source: [linuxyz/krcu-deadly](https://github.com/seantywork/linuxyz/tree/main/krcu-deadly)
+- date: 2509-
+
index 3ea0ec3427f2817c0821fb33dc02749962d32328..23cd92711260174782a2b3cbc1a72e6dc1b047d6 100644 (file)
@@ -5,20 +5,67 @@
 #include <linux/rculist.h>
 #include <linux/spinlock.h>
 #include <linux/preempt.h>
+#include <linux/kthread.h>
+#include <linux/sched/task.h>
+#include <linux/delay.h>
 
+#define OP_COUNT 10
 
+static struct task_struct *task_write;
+static struct task_struct *task_read;
+static int w = 10;
+static int r = 11;
 
+static int task_writer(void *arg){
+
+    int v = *(int *)arg;
+
+    for(int i = 0; i < OP_COUNT; i++){
+        printk(KERN_INFO "rcudeadly: v: %d: w: %d\n", v, i);
+        mdelay(1000);
+    }
+
+    return 0;
+}
+
+static int task_reader(void *arg){
+
+    int v = *(int *)arg;
+
+    for(int i = 0; i < OP_COUNT; i++){
+        printk(KERN_INFO "rcudeadly: v: %d: r: %d\n", v, i);
+        mdelay(1000);
+    }
+
+    return 0;
+}
 
 
 static int __init rcu_deadly_init(void){
 
+    task_write = kthread_run(task_writer, (void*)&w, "tw/%d", w);
+    if(IS_ERR(task_write)){
+        printk(KERN_ERR "rcudeadly: failed to create task_write thread\n");
+        return -1;
+    }
+    task_read = kthread_run(task_reader, (void*)&r, "tr/%d", r);
+    if(IS_ERR(task_read)){
+        printk(KERN_ERR "rcudeadly: failed to create task_read thread\n");
+        return -1;
+    }
+    get_task_struct(task_write);
+    get_task_struct(task_read);
 
+    printk(KERN_INFO "rcudeadly: loaded\n");
 
     return 0;
 }
 
 static void __exit rcu_deadly_exit(void){
+    kthread_stop(task_write);
+    kthread_stop(task_read);
 
+    printk(KERN_INFO "rcudeadly: unloaded\n");
 
 }