如何在内核级别维护链表?
情况是:我将实现多组新的系统调用。他们每个人都需要访问(读或写)一个链表。所以,这意味着我将有几个 C 程序。
那么,如何在内存中维护一个链表并让多个程序访问它呢?或者,这是错误的......我应该将其保存为文件? (但我几乎不认为这是一个好主意)..
The situation is: I will implement sets of new system calls. Each of them need to access (read or write) a linked list. So, that means I will have several C programs.
So, how can I maintain a linked list in memory and let several programs access it? Or,this is wrong....I should save it as a file? (but I hardly think this is a good idea)..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不是内核开发人员,但这是我对如何解决这个问题的猜测...
华泰
I am no kernel developer, but here's my guess at how to go about this...
HTH
@jackrabbit 为你指明了正确的方向。我将添加有关在系统调用之间共享列表的信息。
您的代码将链接到内核本身,或作为可加载模块。无论哪种方式,您的数据可能需要使用“kmalloc”动态分配。这些数据将可供整个内核使用,与用户态程序不同,它驻留在机器内存中。将其视为(内核)线程之间共享的常规指针/数据。
@jackrabbit points you into right direction. I'll add about sharing the list between syscalls.
Your code will be linked into kernel inself, or as a loadable module. Either way your data will probably need to be dynamically allocated with 'kmalloc'. This data will be available to the whole kernel, which unlike userland programs, stays resident in machine memory. Treat it as a regular pointer/data shared between (kernel) threads.
根据您想要执行的操作,您可能需要查看此。
Depending on what you want to do, you might want to check this out.