diff --git a/work/tp3/pipebis3.c b/work/tp3/pipebis3.c index 269b6b22a075e376e59ac0ca87bf3c9fd5547b50..db529cb434be484517432928757d1c0905826d8e 100644 --- a/work/tp3/pipebis3.c +++ b/work/tp3/pipebis3.c @@ -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; diff --git a/work/tp3/pipebis3.mod.c b/work/tp3/pipebis3.mod.c index d4f0c91402bf00ca7f58514cd6fc64b87326c310..de6b143b0c062104b90474a2bb5f0c9e08688e51 100644 --- a/work/tp3/pipebis3.mod.c +++ b/work/tp3/pipebis3.mod.c @@ -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");