lkml.org 
[lkml]   [1999]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: User/Kernel communication
Josh Oakes wrote:
> ....
> I have a kernel module and a userspace program. Each need to be able to
> send messages to the other. I've looked into get_user and put_user but
> they require an address argument from userland. If the address is from
> userland, wouldn't the address be virtual in the process address space?
Ok, that's correct.
> How would the kernel know from which process the pointer came and thus be
> able to translate it to an absolute address? Also, any code that I've seen
> seems to assume that the user code is calling the kernel code and can hence
> pass a pointer.

That code assumes that the process is calling the kernel, because these
functions are called during a system call, ( or fired by an external
interrupt, ... while a proccess is running, ... the acions are taken for
this process).

> Well what if the kernel wants to initiate communication with the user process? > How can they set up a meeting place?
First, you'd be better to evaluate the specific cost for the action you
want to take:
The fisrt option is to implement the mecanism throw message queues
(IPC) between the kernel and each proccess in your model.
Other option is to activate the scheduler, and select the process for
which the kernel-message is, an then, (throw a botton-half rutine) copy
up to the process (that will be the current) the information whith
put_user. This make the job asynchronously.
The thirth option (more efficient, than the second if you want
synchronism) is very ugly and i dont't like it at all. Consists in
hardcoding the second: Switch to the second process memory map (changing
its pgd and memory map) and doind the put_user. Then restore the
original context.

I think yo'd be better implementing the second, but perhaps the first
is the simpliest.

good luck.
--
Luis Irún Briz _______
lirun@iti.upv.es | | de |
www.iti.upv.es/~lirun | | |
U.P.V. - [ www.upv.es ] |nstituto |ecnológico |nformática

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.034 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site