From owner-freebsd-hackers Tue Jul 24 10:13:38 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mass.dis.org (sat.dis.org [216.240.44.14]) by hub.freebsd.org (Postfix) with ESMTP id 773A037B401; Tue, 24 Jul 2001 10:13:27 -0700 (PDT) (envelope-from msmith@mass.dis.org) Received: from mass.dis.org (localhost [127.0.0.1]) by mass.dis.org (8.11.4/8.11.3) with ESMTP id f6O2e3205277; Mon, 23 Jul 2001 19:40:05 -0700 (PDT) (envelope-from msmith@mass.dis.org) Message-Id: <200107240240.f6O2e3205277@mass.dis.org> X-Mailer: exmh version 2.1.1 10/15/1999 To: y-carden@uniandes.edu.co Cc: hackers@freebsd.org, questions@freebsd.org Subject: Re: Invoking a userland function from kernel In-reply-to: Your message of "Mon, 23 Jul 2001 21:27:06 CDT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 23 Jul 2001 19:40:03 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > 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