Re: [question/comment/help] pseudo function-call from kernel to a user-process

Pavel Machek (pavel@suse.cz)
Tue, 9 Nov 1999 21:33:18 +0100


Hi!

> I want to have a pseudo-function-call initiated by the kernel in a
> system-call. The following code(source see below), a systemcall, do the
> following:
>
> 1. a user-process register itself to the kernel. (dkm_csd_pid)
> 2. in a system-call (eg. sys_execve) I send the signal SIGUSR2 to the
> process to initiate the communication.
> 3. the process has a signal-handler for the signal.
> 4. [pseudo-function call begins] the process calls dkmctl with
> DKM_MAP_REQ with a buffer, the kernel copies its argument via
> copy_to_user using the buffer to the process. down a global
> kernel-semaphore to protect this area.
> 5. [in the pseudo-function-call] the process is still in the
> signal-handler and process an answer for the request.
> 6. [pseudo-function-call returns] the process use the system-call dkmctl
> with DKM_MAP_RESP to return the return-value of the
> pseudo-function-call.
> 7. up the global kernel-semaphore to allow other tasks the same.
> 8. now the origin system-call goes on...
> ( while development, I use the cmd DKM_DOSIG to initiate the
> communication, in real life it's done in the real-syscall (execve...))
>
> OK. This works. My Questions:
> - can I do this in an other way ? Is there any functionality in the
> kernel to do somethin like this?
> - as you can see int the code, I tried to use a self-defined spinlock to
> protect the area, but that doesn't work, why? aren't spinlocks like
> semaphores or mutex'es?

Spinlocks are NOP on uniprocessor.

> - are there any pitfalls ?

Yes. Think hard about deadlocks.

Well - when I was about to do something like this (block device in
userland), I called it network block device. Loopback network is quite
nice to use.

> void on_sigusr2(int signal)
> {
> char* node_name;
> char* buff;
>
> node_name = (char*) malloc(64);
> buff = (char*) malloc(64);
>
> printf("sigusr2 from kernel reveived\n");
> dkmctl(DKM_MAP_REQ, buff, NULL);
> printf("buff is: %s\n", buff);
> strcpy(node_name, "orinoco");

What's that? Some kind of distributed system? I WANT THAT!

I have two machines, and would like to use them both for kernel
compiles. Bitcluster has some serious problems :-( and mj's slice is
2.2. only and I was unable to port it.
Pavel

-- 
I'm really pavel@ucw.cz. Look at http://195.113.31.123/~pavel.  Pavel
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!

- 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/