Re: Kernel-userspace shared mutex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mike Tyson a écrit :
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

G'day!

I'm building a system that consists of an 'interface' kernel module, and
a user daemon that does all the work, connected by megabytes of mmap()'d
memory:

              ______
             |     |
             |     |
             |daem-|
             | on  |
             |_____|
                ||
                || mmap()'d memory
             ___||___                  user space
  ___________|______| <- char dev_____
  |          |      |                |
  |          | modu-|                | kernel space
  |          |  le  |                |



I'm after a mutex mechanism that will protect this area, that's
accessible from both user-space and the kernel.

I originally thought spinlock_t would be a good candidate, until I
realised that the spinlock_t of the kernel, and that of
/usr/include/asm/spinlock.h were different.

The other option I can think of is to use atomic_t, and write my own
spinlock.. Which I have no problem doing; it would be a fairly brief
task, presumably.

Before I go ahead and do so, has anyone else been in a similar
situation, or heard of any similar system?
Could there be an alternative I've missed?

Cheers =)

Mike
Hi Mike,

in fact, you can't use the same spinlock in the user mode and in the kernel mode. that's because the adress spaces aren't the same in kernel and user mode.
And generally, you don't share a buffer between kernel and user space.

I don't know exactely what you want to do but I think you have to build a new design of your module.
Looking at the scheme, you seem to use char drivers.
Have a look here :
http://lwn.net/Kernel/LDD3/

If it's a char driver you want to do, implement the buffer in kernel space and just provide the good functionnalities (read,write) so the users will be able to access the data.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux