Comments (6)
@jserv respectfully, the problem with:
static char msg[BUF_LEN];
... in chardev.c still exists. As I understand, device_*
can be called concurrently which will cause concurrent access to msg
and memory corruption as result. Unless there is something I don't know about how Linux kernel modules work. In the latest case I believe it should be clarified in the text and in the comments to the code.
from lkmpg.
Reopen as per @afiskon requested. Under investigation.
from lkmpg.
I am testing the chardev.c on my machine and I think there is still some bug need to be fixed.
In my testing:
`[0] read 0 bytes.
[1] read 0 bytes.
[3] read 40 bytes. I already told you 1 times Hello world!
[2] read 40 bytes. I already told you 1 times Hello world!
[4] read 0 bytes.
[3] read 40 bytes. I already told you 1 times Hello world!
[0] read 0 bytes.
[1] read 40 bytes. I already told you 1 times Hello world!
[2] read 0 bytes.
[4] read 40 bytes. I already told you 1 times Hello world!
`
Sometime, the read function from user space will fail (can't get the message) because the "Offset" in the open file table is not correct.
They all use the same open file table entry so there will also have race condition if we update the offset before device_read() return the bytes_read.
from lkmpg.
I am testing the chardev.c on my machine and I think there is still some bug need to be fixed.
@YLowy, you should discussion in the thread of pull request #108 if you were referring to the offset
specific changes.
from lkmpg.
Due to the offset which is hard to be managed, I think it is a good way to create a list for each reading tasks. The element of the list includes the task's PID and it's offset. So that the race condition in the open file table will not occur. Nevertheless, we still need to consider the list behavior when task close or lseek the device.
from lkmpg.
Close via #108
from lkmpg.
Related Issues (20)
- procfs3.ko used by -1 HOT 2
- procfs2.c vs. procfs3.c HOT 1
- 11.1 Sleep chapter. API module_interruptible_sleep_on HOT 1
- Reason to reset the offset HOT 2
- Smatch repository is unavailable HOT 1
- Build kernel module for Rpi3MB HOT 1
- Building kernel modules in RpiOS32bit/Rpi3MB platform HOT 2
- lkmpg on RpiOsLite/rpi3MB HOT 1
- Consistent usage of __init and __exit HOT 1
- About 16.2 Symmetric key encryption sample code HOT 2
- examples/kbleds.c:64:55: error: ‘struct tty_driver’ has no member named ‘magic’
- Building kbleds.ko on RpiOSLite64bit (Linux 6.1.21-v8+) HOT 4
- examples/sched.ko HOT 4
- Module parameters callback : be notified when a parameter is updated
- Little introduction to debugfs
- About /proc, try_module_get and python3 HOT 3
- If you want to build device drivers for an cross target (yocto build) ... HOT 1
- typo
- Linux HOT 1
- Talking to other subsystems
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lkmpg.