Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2001 19:40:03 -0700
From:      Mike Smith <msmith@freebsd.org>
To:        y-carden@uniandes.edu.co
Cc:        hackers@freebsd.org, questions@freebsd.org
Subject:   Re: Invoking a userland function from kernel 
Message-ID:  <200107240240.f6O2e3205277@mass.dis.org>
In-Reply-To: Your message of "Mon, 23 Jul 2001 21:27:06 CDT." <M2001072321270608082@vaca.uniandes.edu.co> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> Dear Friends 
> 
> I'm incorporating the Real Time Protocol RTP (rfc 1889) to
> FreeBSD 4.0 kernel. 
> 
> Months ago, I compiled successfully the RTP Library API developed
> by Lucent into the FreeBSD kernel with the right logical and technical 
> adjustments for the BSD kernel of course (copyin, copyout, malloc, etc).
> 
> I have changed many of the original  API library functions 
> to kernel systems calls, and it works fine.
> 
> Now, I need invoke a userland function with several parameters 
> from the a function into the kernel.
> 
> How I can do?

You could use a signal handler.

> I don't need return data from userland function to kernel later.
> 
> Well, MyKernelFunction() is only invoked for system calls that 
> the userland process with MyUserlandFunction()	have done before, of
> course. 
> 
> In other words,  MyUserlandFuntion() is into the same userland process that
> invoke the system calls that call to MyKernelFunction(). 

You want this user-level function to run as a callback from the system 
call, or can it be asynchronous?

If it can be async, use a signal handler.  Use a setup function that tells
the kernel where in the process the arguments for the signal handler 
should go, and pick one of the free signals.  Then to invoke the 
function, populate the argument area and send the signal.

Note that signal delivery isn't "reliable", ie. you may not get a 1:1 
relationship between invoking the handler and it running unless you use 
an interlock of some sort.

As a general rule, what you're trying to do is entirely wrong from the 
Unix perspective, and the entire problem needs to be restructured to 
remove the layering violation that this represents.

-- 
... every activity meets with opposition, everyone who acts has his
rivals and unfortunately opponents also.  But not because people want
to be opponents, rather because the tasks and relationships force
people to take different points of view.  [Dr. Fritz Todt]
           V I C T O R Y   N O T   V E N G E A N C E



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200107240240.f6O2e3205277>