Skip to content
Snippets Groups Projects
Commit 47944436 authored by root's avatar root
Browse files

pipebis3.ko working

parent d10977af
Branches main
No related tags found
No related merge requests found
......@@ -211,7 +211,7 @@ static int block_empty_buff(void)
}
if (is_sig) {
module_put(THIS_MODULE);
// module_put(THIS_MODULE);
return -1;
}
......@@ -270,6 +270,11 @@ static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */
mutex_unlock(&asse_buf_count_mutex);
wake_up(&wait_full);
if (asee_buf_count <= 0) {
pr_info("Read blocked\n");
if (block_empty_buff() < 0) return 0;
}
}
*offset = last_read_bytes;
......@@ -292,7 +297,7 @@ static int block_full_buff(void)
}
if (is_sig) {
module_put(THIS_MODULE);
// module_put(THIS_MODULE);
return -1;
}
}
......@@ -328,9 +333,9 @@ static ssize_t device_write(struct file *filp, const char __user *buff,
//pr_info("Waking up empty\n");
wake_up(&wait_empty);
asee_buf_count++;
if (asee_buf_count < asee_buf_size) {
//pr_info("asee_buf_count++;\n");
asee_buf_count++;
mutex_unlock(&asse_buf_count_mutex);
} else {
//pr_info("atomic_set(&already_full, 1); \n");
......@@ -340,16 +345,6 @@ static ssize_t device_write(struct file *filp, const char __user *buff,
}
}
mutex_lock(&asse_buf_count_mutex);
// Le probleme est ici, cela donne zero au debut
pr_info("last_read_bytes: %d", last_read_bytes);
// We change asee_buf_size :TODO handle modulo
last_read_bytes = (last_read_bytes + bytes_writen) % asee_buf_size;
pr_info("bytes_writen: %d", bytes_writen);
pr_info("asee_buf_count: %d", asee_buf_count);
pr_info("Last read byte update to: %d", last_read_bytes);
mutex_unlock(&asse_buf_count_mutex);
*off = last_writen_bytes;
return bytes_writen;
......
......@@ -35,7 +35,6 @@ MODULE_INFO(retpoline, "Y");
static const struct modversion_info ____versions[]
__used __section("__versions") = {
{ 0x1000e51, "schedule" },
{ 0x8c26d495, "prepare_to_wait_event" },
{ 0x92540fbf, "finish_wait" },
{ 0xf0fdf6cb, "__stack_chk_fail" },
......@@ -66,10 +65,11 @@ __used __section("__versions") = {
{ 0x3213f038, "mutex_unlock" },
{ 0xe2c17b5d, "__SCT__might_resched" },
{ 0xfe487975, "init_wait_entry" },
{ 0x1000e51, "schedule" },
{ 0x76800044, "module_layout" },
};
MODULE_INFO(depends, "");
MODULE_INFO(srcversion, "D65D0B5D00F7B86A769F376");
MODULE_INFO(srcversion, "331261CAA2C80075E1CB7DD");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment